merged materiobasemod submodule

This commit is contained in:
Bachir Soussi Chiadmi 2015-04-19 13:47:39 +02:00
commit a494bb4627
56 changed files with 15555 additions and 0 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 B

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,592 @@
/*
* www.g-u-i.net
*/
// =
// =
// =
// =
// =
// ===== TYPOGRAHIE ======================================================================================================
.8(){font-size:8px;}
.9(){font-size:9px;}
.10(){font-size:10px;}
.11(){font-size:10px;}
.12(){font-size:12px;}
.14(){font-size:14px;}
.16(){font-size:16px;}
.18(){font-size:18px;}
.20(){font-size:20px;}
.24(){font-size:24px;}
.28(){font-size:24px;}
.30(){font-size:30px;}
.36(){font-size:36px;}
.48(){font-size:48px;}
.60(){font-size:60px;}
.72(){font-size:72px;}
.regular(){font-weight:normal;}
.bold(){font-weight:bold;}
.100(){font-weight:100;}
.200(){font-weight:200;}
.300(){font-weight:300;}
.400(){font-weight:400;}
.500(){font-weight:500;}
.600(){font-weight:600;}
.700(){font-weight:700;}
.800(){font-weight:800;}
.900(){font-weight:900;}
.upper(){text-transform: uppercase;}
.italic(){font-style:italic;}
.normal(){font-style: normal;}
.hyphens(@value: auto)
{
-webkit-hyphens:@value;
-moz-hyphens:@value;
-ms-hyphens:@value;
-o-hyphens:@value;
hyphens:@value;
}
.font-size(@value: 1em,@lineheight:1.3em)
{
font-size:@value;
line-height:@lineheight;
}
@green:#17942A;
@red:#E60000;
// =
// =
// =
// =
// =
// ===== SHORTCUTS =======================================================================================================
// padding
.p(@p){ padding:@arguments; }
.p(@v, @h){ padding:@arguments; }
.p(@t, @l, @b, @l){ padding:@arguments; }
.pt(@p){ padding-top:@p; }
.pr(@p){ padding-right:@p; }
.pb(@p){ padding-bottom:@p; }
.pl(@p){ padding-left:@p; }
// margin
.m(@p){ margin:@arguments; }
.m(@v, @h){ margin:@arguments; }
.m(@t, @l, @b, @l){ margin:@arguments; }
.mt(@m){ margin-top:@m; }
.mr(@m){ margin-right:@m; }
.mb(@m){ margin-bottom:@m; }
.ml(@m){ margin-left:@m; }
.0(){ margin:0; padding:0; }
// border
.b(@b){ border: @b; }
.b(@size, @color){ border: @size solid @color; }
.bt(@b){ border-top: @b;}
.bt(@size, @color){border-top: @size solid @color;}
.br(@b){ border-right: @b;}
.br(@size, @color){border-right: @size solid @color;}
.bb(@b){ border-bottom: @b;}
.bb(@size, @color){border-bottom: @size solid @color;}
.bl(@b){ border-left: @b;}
.bl(@size, @color){border-left: @size solid @color;}
.bordered(@top-color: #EEE, @right-color: #EEE, @bottom-color: #EEE, @left-color: #EEE)
{
border-top : solid 1px @top-color;
border-right : solid 1px @right-color;
border-bottom: solid 1px @bottom-color;
border-left : solid 1px @left-color;
}
// Background
.bg(@color, @url, @repeat, @scrollfixed, @pos){background: @arguments;}
.bgc(@color){background-color: @arguments;}
.bkgd(@params){background: @arguments;}
.bkgdc(@color){.bgc(@arguments);}
.bgca(@r, @g, @b, @a){
background-color: rgb(@r, @g, @b); // ie8
background-color: rgba(@r, @g, @b, @a);
*background-color: rgb(@r, @g, @b); // ie7
};
// Selection
.selection(@bgcolor,@color)
{
&::selection {
background:@bgcolor;
color:@color;
}
&::-moz-selection {
background:@bgcolor;
color:@color;
}
&::-webkit-selection {
background:@bgcolor;
color:@color;
}
}
// Colors
.color(@value)
{
&,
& *{color:@value;}
}
// Opacity
.opacity(@opacity: 0.5)
{
-webkit-opacity: @opacity;
-khtml-opacity: @opacity;
-moz-opacity: @opacity;
opacity: @opacity;
}
// size
.size(@height, @width) {
width: @width;
height: @height;
}
.square(@size) {
.size(@size, @size);
}
// center
.center-block() {
display: block;
margin-left: auto;
margin-right: auto;
}
// =
// =
// =
// =
// =
// ===== DISPLAY UTILS ===================================================================================================
// Inline blocks
.inlineblock(@align:top)
{
display:moz-inline-stack;
display:inline-block;
vertical-align:@align;
zoom:1;
*display:inline;
.ie7 &, .ie8 &{display:block;float:left;}
}
.db(){display:block;}
.dbn(){display:none;}
.dib(){.inlineblock;}
.dib(@align){.inlineblock(@align);}
.float(@align:left){
.db; float:@align;
}
.abs(@value) { position:absolute; top:@value; left:@value; bottom:@value; right:@value; }
.abs(@top, @left) { position:absolute; top:@top; left:@left; }
.abs(@top, @right, @bottom, @left) { position:absolute; top:@top; left:@left; bottom:@bottom; right:@right; };
.fix(@value) { position:fixed; top:@value; left:@value; bottom:@value; right:@value; }
.fix(@top, @left) { position:fixed; top:@top; left:@left; }
.fix(@top, @right, @bottom, @left) { position:fixed; top:@top; left:@left; bottom:@bottom; right:@right; };
// Columns system
@g:0;
.g() { width:@g; }
.col(@col,@coltotal:@n,@gutter:@g) {
width: @col * ( 100% - ((@coltotal - 1) * @gutter) ) / @coltotal + ((@col - 1) * @gutter);
}
.inside-left(@col,@coltotal:@n,@gutter:@g) {
padding-left: @col * ( 100% - ((@coltotal - 1) * @gutter) ) / @coltotal + (@col * @gutter);
}
.inside-right(@col,@coltotal:@n,@gutter:@g) {
padding-right: @col * ( 100% - ((@coltotal - 1) * @gutter) ) / @coltotal + (@col * @gutter);
}
// Vertical alignement
//
// ___ .align-child()
// |
// | Permet lalignement vertical dun objet par rapport à son premier parent (dans son conteneur direct).
// |
// | 1 param : @vertical-align
//
.align-child(@align:middle){
&:before { content: ""; .dib(middle); overflow: hidden; visibility: hidden; width: 0; height: 100%; }
& > * { .dib(@align); }
}
.clear-after(){
&:after{clear:both;content:'';display:block;height:0px;overflow:hidden;visibility:hidden;width:0px;}
}
// For clearing floats like a boss h5bp.com/q
.clearix() {
*zoom: 1;
&:before,
&:after {
display: table;
content: "";
// Fixes Opera/contenteditable bug:
// http://nicolasgallagher.com/micro-clearfix-hack/#comment-36952
line-height: 0;
}
&:after {
clear: both;
}
}
// =
// =
// =
// =
// =
// ===== CSS3 ============================================================================================================
// Gradients
.gradient(@color: #F5F5F5, @start: #EEE, @stop: #FFF)
{
background: @color;
background: -webkit-gradient(linear,
left bottom,
left top,
color-stop(0, @start),
color-stop(1, @stop));
background: -ms-linear-gradient(bottom,
@start,
@stop);
background: -moz-linear-gradient(center bottom,
@start 0%,
@stop 100%);
}
.bw-gradient(@color: #F5F5F5, @start: 0, @stop: 255)
{
background: @color;
background: -webkit-gradient(linear,
left bottom,
left top,
color-stop(0, rgb(@start,@start,@start)),
color-stop(1, rgb(@stop,@stop,@stop)));
background: -ms-linear-gradient(bottom,
rgb(@start,@start,@start) 0%,
rgb(@start,@start,@start) 100%);
background: -moz-linear-gradient(center bottom,
rgb(@start,@start,@start) 0%,
rgb(@stop,@stop,@stop) 100%);
}
// Shadows
//
// ___ .box-shadow()
// |
// | Ombré extérieur.
// |
// | 1 param : @blur
// | 2+ params : @horizontal / @vertical / @blur / @color: #000 / @spread: 0px
//
// ___ .inset-shadow()
// |
// | Ombré intérieur.
// |
// | 1 param : @blur
// | 2+ params : @horizontal / @vertical / @blur / @color: #000 / @spread: 0px
//
.box-shadow(@blur: 9px)
{
filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=0, OffY=0, Color='#000');
-ms-filter: "progid:DXImageTransform.Microsoft.dropshadow(OffX=0, OffY=0, Color='#000')";
-webkit-box-shadow: 0 0 @blur #000;
-moz-box-shadow: 0 0 @blur #000;
-ms-box-shadow: 0 0 @blur #000;
box-shadow: 0 0 @blur #000;
}
.box-shadow(@x, @y, @blur: 9px, @color: #000, @spread: 0px)
{
filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=@x, OffY=@y, Color=~'@{color}');
-ms-filter: "progid:DXImageTransform.Microsoft.dropshadow(OffX=@{x}, OffY=@{y}, Color='@{color}')";
-webkit-box-shadow: @x @y @blur @spread @color;
-moz-box-shadow: @x @y @blur @spread @color;
-ms-box-shadow: @x @y @blur @spread @color;
box-shadow: @x @y @blur @spread @color;
}
.inset-shadow(@blur: 9px)
{
filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=0, OffY=0, Color='#000');
-ms-filter: "progid:DXImageTransform.Microsoft.dropshadow(OffX=0, OffY=0, Color='#000')";
-webkit-box-shadow: 0 0 @blur #000 inset;
-moz-box-shadow: 0 0 @blur #000 inset;
-ms-box-shadow: 0 0 @blur #000 inset;
box-shadow: 0 0 @blur #000 inset;
}
.inset-shadow(@x, @y, @blur: 9px, @color: #000, @spread: 0px)
{
filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=@x, OffY=@y, Color=~'@{color}');
-ms-filter: "progid:DXImageTransform.Microsoft.dropshadow(OffX=0, OffY=0, Color='@{color}')";
-webkit-box-shadow: @x @y @blur @spread @color inset;
-moz-box-shadow: @x @y @blur @spread @color inset;
-ms-box-shadow: @x @y @blur @spread @color inset;
box-shadow: @x @y @blur @spread @color inset;
}
.drop-shadow(@x-axis: 0, @y-axis: 1px, @blur: 2px, @alpha: 0.1)
{
-webkit-box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);
-moz-box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);
box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);
}
// Border radius
.rounded(@radius: 2px)
{
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
border-radius: @radius;
-webkit-background-clip: padding-box;
-moz-background-clip: padding;
background-clip: padding-box;
}
.border-radius(@topleft: 0, @topright: 0, @bottomright: 0, @bottomleft: 0)
{
-webkit-border-radius:@arguments;
-moz-border-radius:@arguments;
border-radius:@arguments;
-webkit-background-clip: padding-box;
-moz-background-clip: padding;
background-clip: padding-box;
}
// transitions
.transition-simply-prefix(@string) {
-webkit-transition: @string;
-moz-transition: @string;
-o-transition: @string;
transition: @string;
}
//
// ___ .transition()
// |
// | 1 param : @property
// | 2 params : @property / @duration
// | 3+ params : @property / @duration / @transitiondelay:0s , @timingfunction:ease-out
//
// ___ .transitions()
// |
// | Permet de fixer des paramètres spécifique par propriétés, exemple:
// |
// | .transitions(
// | 'height , padding , margin , box-shadow',
// | '.5s , .2s , .2s , .2s',
// | '0s , 0s , 0s , .3s',
// | 'linear , ease-out , linear , ease-out'
// | );
//
.transition(@property: all)
{
-webkit-transition: @property;
-moz-transition: @property;
-o-transition: @property;
transition: @property;
}
.transition(@property, @duration)
{
-webkit-transition: @arguments;
-moz-transition: @arguments;
-o-transition: @arguments;
transition: @arguments;
}
.transition(@property, @duration, @transitiondelay, @timingfunction:ease-out)
{
-webkit-transition: @arguments;
-moz-transition: @arguments;
-o-transition: @arguments;
transition: @arguments;
}
.transitions(@property: all, @duration:0s, @transitiondelay:0s, @timingfunction:ease-out)
{
-webkit-transition-property :~'@{property}';
-webkit-transition-duration :~'@{duration}';
-webkit-transition-delay :~'@{transitiondelay}';
-webkit-transition-timing-function:~'@{timingfunction}';
-moz-transition-property :~'@{property}';
-moz-transition-duration :~'@{duration}';
-moz-transition-delay :~'@{transitiondelay}';
-moz-transition-timing-function:~'@{timingfunction}';
-o-transition-property :~'@{property}';
-o-transition-duration :~'@{duration}';
-o-transition-delay :~'@{transitiondelay}';
-o-transition-timing-function:~'@{timingfunction}';
transition-property :~'@{property}';
transition-duration :~'@{duration}';
transition-delay :~'@{transitiondelay}';
transition-timing-function:~'@{timingfunction}';
}
.transitions-duration(@duration: 0s)
{
-webkit-transition-duration: ~'@{duration}';
-moz-transition-duration: ~'@{duration}';
-o-transition-duration: ~'@{duration}';
transition-duration: ~'@{duration}';
}
.transition-duration(@duration: 0.2s)
{
-webkit-transition-duration: @duration;
-moz-transition-duration: @duration;
-o-transition-duration: @duration;
transition-duration: @duration;
}
.transitions-delay(@delay: 0s)
{
-webkit-transition-delay: ~'@{delay}';
-moz-transition-delay: ~'@{delay}';
-o-transition-delay: ~'@{delay}';
transition-delay: ~'@{delay}';
}
// Rotate
//
// ___ .rotation()
// |
// | 1 param : @degree
//
// ___ .rotate()
// |
// | Tentative de compatibilté étendue (fonctionne uniquement pour 0, 90, 180 ou 270 degrés).
// |
// | 1 param : @degree
// | 3 params : @degree / @originX / @originY
//
.rotation(@deg:5deg)
{
-webkit-transform: rotate(@deg);
-moz-transform: rotate(@deg);
transform: rotate(@deg);
}
.rotate(@value, @originX:0%, @originY:0%, @unit:'deg')
{
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation = (360 / @value) + 1); //0, 1, 2, or 3 rotate 0, 90, 180 or 270
-webkit-transform: rotate(~"@{value}@{unit}"); // ~"@{value}@{unit}" rather than @value@unit remove the spaces between value and unit.
-moz-transform: rotate(~"@{value}@{unit}");
-ms-transform: rotate(~"@{value}@{unit}");
-o-transform: rotate(~"@{value}@{unit}");
transform: rotate(~"@{value}@{unit}");
-webkit-transform-origin:@originX @originY;
-moz-transform-origin:@originX @originY;
-ms-transform-origin:@originX @originY;
-o-transform-origin:@originX @originY;
transform-origin:@originX @originY;
}
// Scale
.scale(@ratio:1.5)
{
-webkit-transform:scale(@ratio);
-moz-transform:scale(@ratio);
transform:scale(@ratio);
}
// Translate
.translate(@x:0, @y:0)
{
-webkit-transform: translate(@x, @y);
-moz-transform: translate(@x, @y);
-ms-transform: translate(@x, @y);
-o-transform: translate(@x, @y);
transform: translate(@x, @y);
}
// Columns
.columns(@colwidth: 250px, @colcount: 0, @colgap: 50px, @columnRuleColor: #EEE, @columnRuleStyle: solid, @columnRuleWidth: 1px)
{
-webkit-column-width : @colwidth;
-webkit-column-count : @colcount;
-webkit-column-gap : @colgap;
-webkit-column-rule-color: @columnRuleColor;
-webkit-column-rule-style: @columnRuleStyle;
-webkit-column-rule-width: @columnRuleWidth;
-moz-column-width : @colwidth;
-moz-column-count : @colcount;
-moz-column-gap : @colgap;
-moz-column-rule-color: @columnRuleColor;
-moz-column-rule-style: @columnRuleStyle;
-moz-column-rule-width: @columnRuleWidth;
column-width : @colwidth;
column-count : @colcount;
column-gap : @colgap;
column-rule-color: @columnRuleColor;
column-rule-style: @columnRuleStyle;
column-rule-width: @columnRuleWidth;
}
.edit-link(@bc:#CCFF2F,@c:#333)
{
.dib;
background-color:@bc;
border:1px solid;
border-color:darken(desaturate(@bc, 35%),15%) darken(desaturate(@bc, 35%),15%) darken(desaturate(@bc, 35%),20%);
.rounded;
color: @c;
cursor: pointer;
.font-size(.8em,1em);
font-weight: normal;
padding: 0.25em 0.75em;
margin-top:.5em;
&:hover{background-color:darken(@bc, 20%);}
&:active{
text-shadow: 0 1px 0 lighten(@bc,5%);
background-color:darken(@bc, 20%);
//.inset-shadow(0,0,2px,darken(@bc,60));
}
}
.loader(@fc:#000,@bc:#ccc,@h:8px,@radius:0px)
{
// Safari/chrome
&::-webkit-progress-bar{background-color:@bc;.rounded(@radius);}
&::-webkit-progress-value{background-color:@fc;.rounded(@radius);}
// Firefox
&{background-color:@bc;.rounded(@radius);height:@h;}
&::-moz-progress-bar{background-color:@fc;.rounded(@radius);}
}
// =
// =
// =
// =
// =
// ===== RETINA ==========================================================================================================
// retina.less
// A helper mixin for applying high-resolution background images (http://www.retinajs.com)
.at2x(@path, @w: auto, @h: auto) {
background-image: url(@path);
@at2x_path: ~`"@{path}".split('.').slice(0, "@{path}".split('.').length - 1).join(".") + "@2x" + "." + "@{path}".split('.')["@{path}".split('.').length - 1]`;
@media all and (-webkit-min-device-pixel-ratio : 1.5) {
background-image: url(@at2x_path);
background-size: @w @h;
}
}

View File

@ -0,0 +1,636 @@
<<<<<<< HEAD
/**
* www.g-u-i.net
*/
/** font */
.8{font-size:8px;}
.9{font-size:9px;}
.10{font-size:10px;}
.11{font-size:10px;}
.12{font-size:12px;}
.14{font-size:14px;}
.16{font-size:16px;}
.18{font-size:18px;}
.20{font-size:18px;}
.24{font-size:24px;}
.28{font-size:28px;}
.30{font-size:30px;}
.36{font-size:36px;}
.48{font-size:48px;}
.60{font-size:60px;}
.72{font-size:72px;}
.regular{font-weight:normal;}
.bold{font-weight:bold;}
.100{font-weight:100;}
.300{font-weight:300;}
.500{font-weight:500;}
.700{font-weight:700;}
.900{font-weight:900;}
.upper{text-transform: uppercase;}
.italic{font-style:italic;}
.normal{font-style: normal;}
/** shortcuts */
=======
/*
* www.g-u-i.net
*/
// =
// =
// =
// =
// =
// ===== TYPOGRAHIE ======================================================================================================
.8(){font-size:8px;}
.9(){font-size:9px;}
.10(){font-size:10px;}
.11(){font-size:10px;}
.12(){font-size:12px;}
.14(){font-size:14px;}
.16(){font-size:16px;}
.18(){font-size:18px;}
.24(){font-size:24px;}
.30(){font-size:30px;}
.36(){font-size:36px;}
.48(){font-size:48px;}
.60(){font-size:60px;}
.72(){font-size:72px;}
.regular(){font-weight:normal;}
.bold(){font-weight:bold;}
.100(){font-weight:100;}
.300(){font-weight:300;}
.500(){font-weight:500;}
.700(){font-weight:700;}
.900(){font-weight:900;}
.upper(){text-transform: uppercase;}
.italic(){font-style:italic;}
.normal(){font-style: normal;}
.hyphens(@value: auto)
{
-webkit-hyphens:@value;
-moz-hyphens:@value;
-ms-hyphens:@value;
-o-hyphens:@value;
hyphens:@value;
}
.font-size(@value: 1em,@lineheight:1.3em)
{
font-size:@value;
line-height:@lineheight;
}
@green:#17942A;
@red:#E60000;
// =
// =
// =
// =
// =
// ===== SHORTCUTS =======================================================================================================
>>>>>>> bitbucket/master
// padding
.p(@p){ padding:@arguments; }
.p(@v, @h){ padding:@arguments; }
.p(@t, @l, @b, @l){ padding:@arguments; }
.pt(@p){ padding-top:@p; }
.pr(@p){ padding-right:@p; }
.pb(@p){ padding-bottom:@p; }
.pl(@p){ padding-left:@p; }
// margin
.m(@p){ margin:@arguments; }
.m(@v, @h){ margin:@arguments; }
.m(@t, @l, @b, @l){ margin:@arguments; }
.mt(@m){ margin-top:@m; }
.mr(@m){ margin-right:@m; }
.mb(@m){ margin-bottom:@m; }
.ml(@m){ margin-left:@m; }
.0(){ margin:0; padding:0; }
// border
.b(@b){ border: @b; }
.b(@size, @color){ border: @size solid @color; }
.bt(@b){ border-top: @b;}
.bt(@size, @color){border-top: @size solid @color;}
.br(@b){ border-right: @b;}
.br(@size, @color){border-right: @size solid @color;}
.bb(@b){ border-bottom: @b;}
.bb(@size, @color){border-bottom: @size solid @color;}
.bl(@b){ border-left: @b;}
.bl(@size, @color){border-left: @size solid @color;}
.bordered(@top-color: #EEE, @right-color: #EEE, @bottom-color: #EEE, @left-color: #EEE)
{
border-top : solid 1px @top-color;
border-right : solid 1px @right-color;
border-bottom: solid 1px @bottom-color;
border-left : solid 1px @left-color;
}
// Background
.bg(@color, @url, @repeat, @scrollfixed, @pos){background: @arguments;}
.bgc(@color){background-color: @arguments;}
.bkgd(@params){background: @arguments;}
.bkgdc(@color){.bgc(@arguments);}
<<<<<<< HEAD
// opacity
.opacity(@opacity: 0.5) {
-moz-opacity: @opacity;
-khtml-opacity: @opacity;
-webkit-opacity: @opacity;
opacity: @opacity;
}
/** Inline blocks */
.inlineblock(){
display:moz-inline-stack;
display:inline-block;
vertical-align:top;
zoom:1;
*display:inline;
/* margin-right:-.25em;*/
.ie7 &{display:inline;}
}
// selection style
.selection(@bgcolor,@color){
=======
// Selection
.selection(@bgcolor,@color)
{
>>>>>>> bitbucket/master
&::selection {
background:@bgcolor;
color:@color;
}
&::-moz-selection {
background:@bgcolor;
color:@color;
}
&::-webkit-selection {
background:@bgcolor;
color:@color;
}
}
// Colors
.color(@value)
{
&,
& *{color:@value;}
}
// Opacity
.opacity(@opacity: 0.5)
{
-webkit-opacity: @opacity;
-khtml-opacity: @opacity;
-moz-opacity: @opacity;
opacity: @opacity;
}
// size
.size(@height, @width) {
width: @width;
height: @height;
}
.square(@size) {
.size(@size, @size);
}
// center
.center-block() {
display: block;
margin-left: auto;
margin-right: auto;
}
// =
// =
// =
// =
// =
// ===== DISPLAY UTILS ===================================================================================================
// Inline blocks
.inlineblock(@align:top)
{
display:moz-inline-stack;
display:inline-block;
vertical-align:@align;
zoom:1;
*display:inline;
.ie7 &, .ie8 &{display:block;float:left;}
}
.db(){display:block;}
.dib(){.inlineblock;}
.dib(@align){.inlineblock(@align);}
// Vertical alignement
//
// ___ .align-child()
// |
// | Permet lalignement vertical dun objet par rapport à son premier parent (dans son conteneur direct).
// |
// | 1 param : @vertical-align
//
.align-child(@align:middle){
&:before { content: ""; .dib(middle); overflow: hidden; visibility: hidden; width: 0; height: 100%; }
& > * { .dib(@align); }
}
.clear-after(){
&:after{clear:both;content:'';display:block;height:0px;overflow:hidden;visibility:hidden;width:0px;}
}
// For clearing floats like a boss h5bp.com/q
.clearix() {
*zoom: 1;
&:before,
&:after {
display: table;
content: "";
// Fixes Opera/contenteditable bug:
// http://nicolasgallagher.com/micro-clearfix-hack/#comment-36952
line-height: 0;
}
&:after {
clear: both;
}
}
// =
// =
// =
// =
// =
// ===== CSS3 ============================================================================================================
// Gradients
.gradient(@color: #F5F5F5, @start: #EEE, @stop: #FFF)
{
background: @color;
background: -webkit-gradient(linear,
left bottom,
left top,
color-stop(0, @start),
color-stop(1, @stop));
background: -ms-linear-gradient(bottom,
@start,
@stop);
background: -moz-linear-gradient(center bottom,
@start 0%,
@stop 100%);
}
.bw-gradient(@color: #F5F5F5, @start: 0, @stop: 255)
{
background: @color;
background: -webkit-gradient(linear,
left bottom,
left top,
color-stop(0, rgb(@start,@start,@start)),
color-stop(1, rgb(@stop,@stop,@stop)));
background: -ms-linear-gradient(bottom,
rgb(@start,@start,@start) 0%,
rgb(@start,@start,@start) 100%);
background: -moz-linear-gradient(center bottom,
rgb(@start,@start,@start) 0%,
rgb(@stop,@stop,@stop) 100%);
}
// Shadows
//
// ___ .box-shadow()
// |
// | Ombré extérieur.
// |
// | 1 param : @blur
// | 2+ params : @horizontal / @vertical / @blur / @color: #000 / @spread: 0px
//
// ___ .inset-shadow()
// |
// | Ombré intérieur.
// |
// | 1 param : @blur
// | 2+ params : @horizontal / @vertical / @blur / @color: #000 / @spread: 0px
//
.box-shadow(@blur: 9px)
{
filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=0, OffY=0, Color='#000');
-ms-filter: "progid:DXImageTransform.Microsoft.dropshadow(OffX=0, OffY=0, Color='#000')";
-webkit-box-shadow: 0 0 @blur #000;
-moz-box-shadow: 0 0 @blur #000;
-ms-box-shadow: 0 0 @blur #000;
box-shadow: 0 0 @blur #000;
}
.box-shadow(@x, @y, @blur: 9px, @color: #000, @spread: 0px)
{
filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=@x, OffY=@y, Color=~'@{color}');
-ms-filter: "progid:DXImageTransform.Microsoft.dropshadow(OffX=@{x}, OffY=@{y}, Color='@{color}')";
-webkit-box-shadow: @x @y @blur @spread @color;
-moz-box-shadow: @x @y @blur @spread @color;
-ms-box-shadow: @x @y @blur @spread @color;
box-shadow: @x @y @blur @spread @color;
}
.inset-shadow(@blur: 9px)
{
filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=0, OffY=0, Color='#000');
-ms-filter: "progid:DXImageTransform.Microsoft.dropshadow(OffX=0, OffY=0, Color='#000')";
-webkit-box-shadow: 0 0 @blur #000 inset;
-moz-box-shadow: 0 0 @blur #000 inset;
-ms-box-shadow: 0 0 @blur #000 inset;
box-shadow: 0 0 @blur #000 inset;
}
.inset-shadow(@x, @y, @blur: 9px, @color: #000, @spread: 0px)
{
filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=@x, OffY=@y, Color=~'@{color}');
-ms-filter: "progid:DXImageTransform.Microsoft.dropshadow(OffX=0, OffY=0, Color='@{color}')";
-webkit-box-shadow: @x @y @blur @spread @color inset;
-moz-box-shadow: @x @y @blur @spread @color inset;
-ms-box-shadow: @x @y @blur @spread @color inset;
box-shadow: @x @y @blur @spread @color inset;
}
// Border radius
.rounded(@radius: 2px)
{
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
border-radius: @radius;
-webkit-background-clip: padding-box;
-moz-background-clip: padding;
background-clip: padding-box;
}
.border-radius(@topleft: 0, @topright: 0, @bottomright: 0, @bottomleft: 0)
{
-webkit-border-radius:@arguments;
-moz-border-radius:@arguments;
border-radius:@arguments;
-webkit-background-clip: padding-box;
-moz-background-clip: padding;
background-clip: padding-box;
}
<<<<<<< HEAD
// transitions
.transition-simply-prefix(@string) {
-webkit-transition: @string;
-moz-transition: @string;
-o-transition: @string;
transition: @string;
=======
// Transition
//
// ___ .transition()
// |
// | 1 param : @property
// | 2 params : @property / @duration
// | 3+ params : @property / @duration / @transitiondelay:0s , @timingfunction:ease-out
//
// ___ .transitions()
// |
// | Permet de fixer des paramètres spécifique par propriétés, exemple:
// |
// | .transitions(
// | 'height , padding , margin , box-shadow',
// | '.5s , .2s , .2s , .2s',
// | '0s , 0s , 0s , .3s',
// | 'linear , ease-out , linear , ease-out'
// | );
//
.transition(@property: all)
{
-webkit-transition: @property;
-moz-transition: @property;
-o-transition: @property;
transition: @property;
>>>>>>> bitbucket/master
}
.transition(@property, @duration)
{
-webkit-transition: @arguments;
-moz-transition: @arguments;
-o-transition: @arguments;
transition: @arguments;
}
.transition(@property, @duration, @transitiondelay, @timingfunction:ease-out)
{
-webkit-transition: @arguments;
-moz-transition: @arguments;
-o-transition: @arguments;
transition: @arguments;
}
.transitions(@property: all, @duration:0s, @transitiondelay:0s, @timingfunction:ease-out)
{
-webkit-transition-property :~'@{property}';
-webkit-transition-duration :~'@{duration}';
-webkit-transition-delay :~'@{transitiondelay}';
-webkit-transition-timing-function:~'@{timingfunction}';
-moz-transition-property :~'@{property}';
-moz-transition-duration :~'@{duration}';
-moz-transition-delay :~'@{transitiondelay}';
-moz-transition-timing-function:~'@{timingfunction}';
-o-transition-property :~'@{property}';
-o-transition-duration :~'@{duration}';
-o-transition-delay :~'@{transitiondelay}';
-o-transition-timing-function:~'@{timingfunction}';
transition-property :~'@{property}';
transition-duration :~'@{duration}';
transition-delay :~'@{transitiondelay}';
transition-timing-function:~'@{timingfunction}';
}
<<<<<<< HEAD
.transition(@p, @d, @e, @de) {
-webkit-transition: @arguments;
-moz-transition: @arguments;
-o-transition: @arguments;
transition: @arguments;
}
.transition-delay(@delay: 0s) {
-webkit-transition-delay: @delay;
-moz-transition-delay: @delay;
-o-transition-delay: @delay;
transition-delay: @delay;
}
// rotation
.rotation(@deg:5deg){
=======
.transitions-duration(@duration: 0s)
{
-webkit-transition-duration: ~'@{duration}';
-moz-transition-duration: ~'@{duration}';
-o-transition-duration: ~'@{duration}';
transition-duration: ~'@{duration}';
}
.transition-duration(@duration: 0.2s)
{
-webkit-transition-duration: @duration;
-moz-transition-duration: @duration;
-o-transition-duration: @duration;
transition-duration: @duration;
}
// Rotate
//
// ___ .rotation()
// |
// | 1 param : @degree
//
// ___ .rotate()
// |
// | Tentative de compatibilté étendue (fonctionne uniquement pour 0, 90, 180 ou 270 degrés).
// |
// | 1 param : @degree
// | 3 params : @degree / @originX / @originY
//
.rotation(@deg:5deg)
{
>>>>>>> bitbucket/master
-webkit-transform: rotate(@deg);
-moz-transform: rotate(@deg);
transform: rotate(@deg);
}
.rotate(@value, @originX:0%, @originY:0%, @unit:'deg')
{
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation = (360 / @value) + 1); //0, 1, 2, or 3 rotate 0, 90, 180 or 270
-webkit-transform: rotate(~"@{value}@{unit}"); // ~"@{value}@{unit}" rather than @value@unit remove the spaces between value and unit.
-moz-transform: rotate(~"@{value}@{unit}");
-ms-transform: rotate(~"@{value}@{unit}");
-o-transform: rotate(~"@{value}@{unit}");
transform: rotate(~"@{value}@{unit}");
-webkit-transform-origin:@originX @originY;
-moz-transform-origin:@originX @originY;
-ms-transform-origin:@originX @originY;
-o-transform-origin:@originX @originY;
transform-origin:@originX @originY;
}
// Scale
.scale(@ratio:1.5)
{
-webkit-transform:scale(@ratio);
<<<<<<< HEAD
-moz-transform:scale(@ratio);
transform:scale(@ratio);
}
// columns
.columns(@colwidth: 250px) {
-moz-column-width: @colwidth;
-webkit-column-width: @colwidth;
column-width: @colwidth;
}
.columns(@colwidth: 250px, @colcount: 0, @colgap: 50px, @columnRuleColor: #EEE, @columnRuleStyle: solid, @columnRuleWidth: 1px) {
-moz-column-width: @colwidth;
-moz-column-count: @colcount;
-moz-column-gap: @colgap;
-moz-column-rule-color: @columnRuleColor;
-moz-column-rule-style: @columnRuleStyle;
-moz-column-rule-width: @columnRuleWidth;
-webkit-column-width: @colwidth;
-webkit-column-count: @colcount;
-webkit-column-gap: @colgap;
=======
-moz-transform:scale(@ratio);
transform:scale(@ratio);
}
// Translate
.translate(@x:0, @y:0)
{
-webkit-transform: translate(@x, @y);
-moz-transform: translate(@x, @y);
-ms-transform: translate(@x, @y);
-o-transform: translate(@x, @y);
transform: translate(@x, @y);
}
// Columns
.columns(@colwidth: 250px, @colcount: 0, @colgap: 50px, @columnRuleColor: #EEE, @columnRuleStyle: solid, @columnRuleWidth: 1px)
{
-webkit-column-width : @colwidth;
-webkit-column-count : @colcount;
-webkit-column-gap : @colgap;
>>>>>>> bitbucket/master
-webkit-column-rule-color: @columnRuleColor;
-webkit-column-rule-style: @columnRuleStyle;
-webkit-column-rule-width: @columnRuleWidth;
-moz-column-width : @colwidth;
-moz-column-count : @colcount;
-moz-column-gap : @colgap;
-moz-column-rule-color: @columnRuleColor;
-moz-column-rule-style: @columnRuleStyle;
-moz-column-rule-width: @columnRuleWidth;
column-width : @colwidth;
column-count : @colcount;
column-gap : @colgap;
column-rule-color: @columnRuleColor;
column-rule-style: @columnRuleStyle;
column-rule-width: @columnRuleWidth;
}
.edit-link(@bc:#CCFF2F,@c:#333)
{
.dib;
background-color:@bc;
border:1px solid;
border-color:darken(desaturate(@bc, 35%),15%) darken(desaturate(@bc, 35%),15%) darken(desaturate(@bc, 35%),20%);
.rounded;
color: @c;
cursor: pointer;
.font-size(.8em,1em);
font-weight: normal;
padding: 0.25em 0.75em;
margin-top:.5em;
&:hover{background-color:darken(@bc, 20%);}
&:active{
text-shadow: 0 1px 0 lighten(@bc,5%);
background-color:darken(@bc, 20%);
//.inset-shadow(0,0,2px,darken(@bc,60));
}
}
// =
// =
// =
// =
// =
// ===== RETINA ==========================================================================================================
// retina.less
// A helper mixin for applying high-resolution background images (http://www.retinajs.com)
.at2x(@path, @w: auto, @h: auto) {
background-image: url(@path);
@at2x_path: ~`"@{path}".split('.').slice(0, "@{path}".split('.').length - 1).join(".") + "@2x" + "." + "@{path}".split('.')["@{path}".split('.').length - 1]`;
@media all and (-webkit-min-device-pixel-ratio : 1.5) {
background-image: url(@at2x_path);
background-size: @w @h;
}
}

View File

@ -0,0 +1,713 @@
// @codekit-prepend "gui.js"
// @koala-prepend "gui.js"
(function($) {
MaterioFlag = function(){
var _isLoadingList = false ;
/**
* init()
*/
function init(){
//trace('MaterioFlag :: init MaterioFlag');
buildBlocks();
$(document)
.bind('flagGlobalAfterLinkUpdate', onFlaging)
.bind('resultscompleted resultschanged previewloaded', onResultsUpdated)
.bind('init-scroller-pager', onInitScrollerPager)
.bind('load-scroller-pager', onLoadScrollerPager)
.bind('view-mode-changed', onViewModeChanged)
.bind('history-state-change', onHistoryStateChange);
// ajaxifyLinks();
// trigger updated event for direct html loading
if(isList()){
setTimeout(function(){
triggerContentChanged();
}, 10);
}
};
function onFlaging(event){
//trace('MaterioFlag :: onFlaging', event);
refreshBlocks();
};
function onResultsUpdated(event){
//trace('MaterioFlag :: onResultsUpdated', event);
ajaxifyLinks(event.container);
};
function buildBlocks(activename){
//trace('MaterioFlag :: buildBlocks | activename', activename);
if($('#block-materio-flag-materio-flag-mybookmarks').length){
var type = 'bookmarks';
var block = '#block-materio-flag-materio-flag-mybookmarks';
}else if($('#block-materio-flag-materio-flag-mylists').length){
var type = 'lists';
var block = '#block-materio-flag-materio-flag-mylists';
}
switch(type){
case 'bookmarks':
var name = type;
$('h2 .listname', block).attr('name', name).bind('click', onClickShowPreview);
$('<i class="icon-remove"></i>').appendTo($('h2', block)).attr('name', name).bind('click', onClickClosePreview);
// $('<span class="preview"><i class="icon-eye-open"></i></span>').appendTo($('h2', block)).bind('click', onClickShowPreview);
// if(!readCookie('materiobookmarkspreviewopened')){
// showPreview('bookmarks', block);
// }else{
// }
break;
case 'lists':
// nav block
$('a.open-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists-nav').each(function(index){
//trace('nav block a.open-list this', this);
$this = $(this)
.bind('click', onClickOpenLink)
.addClass('ajax-processed');
var name = $this.attr('class').match(/flag_lists_[^_]+_[0-9]+/);
// trace('MaterioFlag :: name', name);
$('<span class="preview"><i class="icon-eye-open"></i></span>').attr('name', name).insertAfter($this).bind('click', onClickShowPreview);
});
$('a.edit-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists-nav')
.bind('click', onCLickEditList)
.addClass('ajax-processed');
$('a.flag-lists-create:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists-nav')
.bind('click', onClickCreatLink)
.addClass('ajax-processed');
// preview block
$('section.flag-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists').each(function(index){
var name = $(this).attr('class').match(/flag_lists_[^_]+_[0-9]+/);
$('<i class="icon-remove"></i>').appendTo($('h2.listname', this)).attr('name', name).bind('click', onClickClosePreview);
$('a.open-list', this).bind('click', onClickOpenLink);
}).addClass('ajax-processed');
break;
}
// trigger refresh block event for enabling lazyload images
setTimeout(function(){
$.event.trigger({
type : 'my'+type+'-block-builded',
block : block,
name : name
});
},10);
// trace('MaterioFlag :: activename', activename);
if(activename == undefined)
activename = readCookie('materiomyflaglistsopened');
// trace('MaterioFlag :: activename', activename);
if(activename)
showPreview(activename, block);
};
function refreshBlocks(name){
//trace('MaterioFlag :: refreshBlocks | name', name);
if($('#block-materio-flag-materio-flag-mybookmarks').length){
var type = 'bookmarks';
}else if($('#block-materio-flag-materio-flag-mylists').length){
var type = 'lists';
}
if(type != undefined){
var id = '#block-materio-flag-materio-flag-my'+type;
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/refresh/block/'+type;
$.getJSON(url, function(json){
// trace('MaterioFlag :: block refreshed '+type, json);
$(id).replaceWith(json.block);
$('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav);
buildBlocks(name);
$.event.trigger({
type : 'my'+type+'-block-updated',
listname : name
});
});
}
};
function ajaxifyLinks(container){
//trace('MaterioFlag :: ajaxifyLinks', container);
container = ((container != null) ? container : 'body');
// trace('MaterioFlag :: typeof Drupal.flagLink', typeof Drupal.flagLink);
if (typeof Drupal.flagLink != 'undefined')
Drupal.flagLink(container);
if(isList()){
var fid = $('.materio-flags-list', '#content').attr('fid');
$('li.unflag-action.fid-'+fid+' a:not(.ajax-processed), li.flag-bookmarks a.unflag-action:not(.ajax-processed)')
.bind('click', onUnflagList)
.addClass('ajax-processed');
}
$('a.flag-lists-create:not(.ajax-processed)', container)
.bind('click', onClickCreatLink)
.addClass('ajax-processed');
};
/**
* show hide preview
*/
function onClickShowPreview(event){
//trace('MaterioFlag :: onClickShowPreview', event);
showPreview($(this).attr('name'), $(this).parent('.block').attr('id'));
};
function showPreview(name, block){
//trace('MaterioFlag :: showPreview', name);
$('section.'+name, block).addClass('active')
.siblings('section').removeClass('active');
createCookie('materiomyflaglistsopened', name, 1);
$.event.trigger('init-layout');
};
function onClickClosePreview(event){
//trace('MaterioFlag :: onClickClosePreview', event);
eraseCookie('materiomyflaglistsopened');
if($(this).attr('name') == 'bookmarks'){
$(this).parents('.block').find('section.bookmarks').removeClass('active');
}else{
$(this).parents('section.flag-list').removeClass('active');
}
$.event.trigger('init-layout');
};
/**
* onClickOpenLink
*/
function onClickOpenLink(event){
event.preventDefault();
var $link = $(event.currentTarget);
var fid = $link.attr('href').match(/lists\/([0-9]+)$/);
// trace('MaterioFlag :: type', type);
loadList(fid[1]);
return false;
};
function loadList(fid){
//trace('MaterioFlag :: loadList | fid', fid);
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/ajax/list/'+fid;
$.event.trigger('loading-content');
$.getJSON(url, {'current_path':document.location.href},function(json){
//trace('MaterioFlag :: json', json);
if(json.redirect){
window.location = json.redirect;
}else{
changeContent(json);
}
});
};
function changeContent(json){
if(json.rendered){
$('.inner-content','#content').html(json.rendered);
$.event.trigger('loaded-content');
// no need of ajaxifylinks because it's triggered with resultschanged
// ajaxifyLinks('#content');
var path = Drupal.settings.basePath + Drupal.settings.pathPrefix + json.path;
$.event.trigger({
type : 'new-history-page',
path : path,
title : json.title,
content : json.rendered
});
// TODO: change language links for folders
// for (language in Drupal.settings.materio_search_api_ajax.languages) {
// var l = Drupal.settings.materio_search_api_ajax.languages[language];
// $('#block-locale-language li.'+language+' a').attr('href', Drupal.settings.basePath + l.prefix+'/' + json.search_path + '/' + json.keys)
// };
triggerContentChanged();
}else{
//trace('MaterioFlag :: no results');
}
};
function triggerContentChanged(){
$.event.trigger({
type: 'resultschanged',
container : '#content .flaglist-items'
});
};
/**
* onClickCreatLink(event)
*/
function onClickCreatLink(event){
//trace('MaterioFlag :: onClickCreatLink | event', event);
event.preventDefault();
var $link = $(event.currentTarget);
var type = $link.attr('href').match(/[^\/]*$/);
// trace('MaterioFlag :: type', type);
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/createlist/form/'+type[0];
$.getJSON(url, function(json){
//trace('MaterioFlag :: creat list : json', json);
showCreateListForm(json, $link);
});
return false;
};
function showCreateListForm(json, $link){
//trace('MaterioFlag :: showCreateListForm | json', json);
// google analytics
$.event.trigger({
type:"record-stat",
categorie:"flagLists",
action: 'show create form'
});
var $modal = $('<div id="modal" class="modal"/>').appendTo('body');
$modal
.css({
position:'absolute',
top:'40%', left:'50%',
marginLeft:'-150px', width:'300px',
zIndex:"99999"
})
.append(json.rendered_form)
.find('input[type="submit"]', '#materio-flag-create-list-form').bind('click', function(event) {
event.preventDefault();
switch($(this).attr('name')){
case 'cancel':
//trace('MaterioFlag :: cancel',event);
$(this).parents('#modal').remove();
// google analytics
$.event.trigger({
type:"record-stat",
categorie:"flagLists",
action: 'cancel create form'
});
break;
case 'create':
//trace('MaterioFlag :: create',event);
var title = $(this).parents('form').find('input[name*="flag-lists-name"]').val();
var type = $(this).parents('form').find('input[name*="type"]').val();
// google analytics
$.event.trigger({
type : "record-stat",
categorie : "flagLists",
action : "submit create form",
label : 'title : '+title
});
createList($modal, type, title, $link);
break;
}
return false;
})
.parents('form').find('input[type="text"]').focus();
// TODO: esc keypressed close the form
};
function createList($modal, type, title, $link){
//trace('materioflag :: createList | title', title);
$('.flag-lists-create').addClass('loading');
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'flag-lists/add/'+type+'/js';
$.getJSON(url, {name:title}, function(data) {
if (data.error) {
//trace(data.error);
}
else {
// select.append('<option value="'+data.flag.fid+'">'+data.flag.title+'</option>');
// $('input.name', $(this)).val('');
// dialog.dialog('close');
//trace('MaterioFlag :: created list : data', data);
if($link.attr('nid') && $link.attr('token')){
flagEntityWithList(data.flag.name, $link.attr('nid'), $link.attr('token'));
}else{
refreshBlocks(data.flag.name);
refreshNodeLinks();
}
$modal.remove();
}
});
};
function flagEntityWithList(name, nid, token){
//trace('MaterioFlag :: flagEntityWithList | name', name);
// var ret;
// Send POST request
$.ajax({
type: 'POST',
url: Drupal.settings.basePath+Drupal.settings.pathPrefix+'flag-lists/flag/'+name+'/'+nid,
data: { js: true, token: token },
dataType: 'json',
success: function (data2) {
//trace('MaterioFlag :: node taged with newly created list : data2', data2)
if (data2.status) {
// google analytics
$.event.trigger({
type : "record-stat",
categorie : 'FlagLists',
action : 'node flaged',
label : 'nid : '+nid+' | flag : '+name
});
refreshBlocks(name);
refreshNodeLinks();
}else {
// Failure.
alert(data2.errorMessage);
}
},
error: function (xmlhttp) {
alert('An HTTP error '+ xmlhttp.status +' occurred.\n'+ element.href);
}
});
};
function refreshNodeLinks(){
//trace('MaterioFlag :: refreshNodeLinks');
var nids = new Array();
$('.flag-lists-entity-links')
// .addClass('loading')
.parents('.node')
.each(function(index) {
nids.push($(this).attr('class').match(/node-([0-9]+)/)[1]);
});
// trace('MaterioFlag :: nids', nids);
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/nodelinks';
$.getJSON(url, {nids:nids.join(";")}, function(data) {
// trace('MaterioFlag :: data', data);
for(nid in data.links){
// trace('MaterioFlag :: nid', nid);
// trace('MaterioFlag :: data.links[nid]', data.links[nid]);
$('.node-'+nid+' .flag-lists-entity-links').replaceWith(data.links[nid]);
// trace('MaterioFlag :: typeof Drupal.flagLink', typeof Drupal.flagLink);
// if (typeof Drupal.flagLink != 'undefined')
// Drupal.flagLink($('.node-'+nid+' .flag-lists-entity-links'));
// TODO: sortir ajaxifyLinks de la boucle, je pense que ça prend trop de ressources
ajaxifyLinks('.node-'+nid+' .flag-lists-entity-links');
}
});
$.event.trigger({
type : 'materioflag-nodelinks-updated',
nids : nids
});
};
/**
* onCLickEditList(event)
*/
function onCLickEditList(event){
//trace('MaterioFlag :: onCLickEditList | event', event);
// TODO: empécher le double formulaire
event.preventDefault();
var $link = $(event.currentTarget);
var lid = $link.attr('href').match(/[^\/]*$/);
var type = 'materiau'; // this is cheap
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/editlistform/'+type+'/'+lid[0];
$.getJSON(url, function(json){
//trace('MaterioFlag :: editlist : json', json);
showEditListForm(json, $link);
});
return false;
};
function showEditListForm(json, $link){
//trace('MaterioFlag :: showEditListForm | json', json);
// google analytics
$.event.trigger({
type:"record-stat",
categorie:"flagLists",
action: 'show edit form'
});
var $modal = $('<div id="modal" class="modal"/>').appendTo('body');
$modal
.css({
position:'absolute',
top:'40%', left:'50%',
marginLeft:'-150px', width:'300px',
zIndex:"99999"
})
.append(json.rendered_form)
.find('input[type="submit"]', '#materio-flag-edit-list-form').bind('click', function(event) {
event.preventDefault();
var $form = $(this).parents('form');
var title = $form.find('input[name*="flag-lists-title"]').val();
var fid = $form.find('input[name*="fid"]').val();
var name = $form.find('input[name*="name"]').val();
switch($(this).attr('name')){
case 'cancel':
//trace('MaterioFlag :: cancel',event);
$(this).parents('#modal').remove();
// google analytics
var action = 'cancel edit form';
break;
case 'save':
//trace('MaterioFlag :: create',event);
// google analytics
var action = "submit edit form";
saveList($modal, fid, name, title);
break;
case 'delete':
//trace('MaterioFlag :: delete',event);
if(confirm('Do you realy want to delete your '+title+' folder ?')){
var action = "submit delete form";
deleteList($modal, fid);
}else{
var action = "cancel delete form";
}
break;
}
// google analytics
$.event.trigger({
type:"record-stat",
categorie:"flagLists",
action: action
});
return false;
})
.parents('form').find('input[type="text"]').focus();
// TODO: esc keypressed close the form
};
function saveList($modal, fid, name, title){
//trace('MaterioFlag :: saveList | fid : '+fid+'| name', name);
$('.flag-lists-link.fid-'+fid).addClass('loading');
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/editlist/'+fid+'/'+name+'/'+title;
$.getJSON(url, function(data) {
if (data.error) {
// trace(data.error);
if(data.message)
alert(data.message);
}
else {
//trace('MaterioFlag :: saved list : data', data);
$.event.trigger({
type : 'list-edited',
name : data.listname,
title : data.title,
});
refreshBlocks();
refreshNodeLinks();
$modal.remove();
}
});
};
function deleteList($modal, fid){
//trace('MaterioFlag :: deletelist | fid', fid);
$('.flag-lists-link.fid-'+fid).hide();
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/deletelist/'+fid;
$.getJSON(url, function(data) {
if (data.error) {
// trace(data.error);
if(data.message)
alert(data.message);
}
else {
//trace('MaterioFlag :: deleted list : data', data);
refreshBlocks();
refreshNodeLinks();
// TODO: if the deleted list was the current displayed list ??
$modal.remove();
}
});
};
/**
* onUnflagList()
*/
function onUnflagList(event){
//trace('onUnflagList', event);
$(this).parents('article.node').addClass('removed');
};
/**
*
*/
function onInitScrollerPager(event){
// trace('MaterioFlag :: MaterioFlag :: onInitScrollerPager');
if (isList()){
// trace('MaterioFlag :: event.pager', event);
event.pager.hide();
}
};
function onLoadScrollerPager(event){
if (isList())
loadNextListPage(event.href);
};
function loadNextListPage(href){
// trace('MaterioFlag :: loadNextListPage', href);
if(!_isLoadingList){
var fid = href.match(/lists\/([^\/|\?]+)/);
var page = href.match(/\?page=([0-9]+)/);
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/ajax/list/'+fid[1]+'/'+page[1];
// trace('MaterioFlag :: url', url);
loadNextPage(url, $('.materio-flags-list', '#content'), '.flaglist-items');
}
};
function loadNextPage(url, $container, target){
//trace('MaterioFlag :: loadNextPage');
_isLoadingList = true;
$container.addClass('loading');
$.getJSON(url, function(json){
//trace('json', json);
_isLoadingList = false;
$container.removeClass('loading');
addNextpage(json, target);
});
};
function addNextpage(json, container_class){
var $newcontent = $(json.rendered),
$newitems = $(container_class, $newcontent).children('article').addClass('just-added'),
$newpager = $('ul.pager', $newcontent);
$(container_class, '#content').append($newitems);
$('ul.pager', '#content').replaceWith($newpager.hide());
// TODO: animation, this should be on theme side
$(container_class, '#content').children('.just-added').each(function(i){
// $(this).delay(5000*i).removeClass('just-added');
var $this = $(this);
setTimeout(function(){
$this.removeClass('just-added');
}, 150*i);
});
$.event.trigger({
type : 'resultscompleted',
container : $(container_class, '#content')
});
};
function onViewModeChanged(event){
if (isList())
loadList(getFid());
};
/**
* history
*/
function onHistoryStateChange(event){
if(isList())
triggerContentChanged();
};
/**
* Helpers
*/
function getFid(){
return $('.materio-flags-list', '#content').attr('fid');;
};
function isList(){
return $('.materio-flags-list', '#content').length;
};
/**
* cookies
*/
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name,"",-1);
}
init();
};
$(document).ready(function() {
var materioflag = new MaterioFlag();
});
})(jQuery);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,44 @@
// @codekit-prepend "gui.js"
// @koala-prepend "gui.js"
(function($) {
MaterioPageTitle = function(){
function init(){
$(document)
.bind('materio-page-title-refresh-block', onRefreshBlock)
.bind('list-edited', onListEdited);
};
function onRefreshBlock(event){
trace('MaterioPageTitle :: onRefreshBlock', event);
// var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_page_title/refresh/block';
// $.getJSON(url, function(json){
// trace('page title json', json);
// $('#block-materio-page-title-materio-page-title').replaceWith(json.block);
// });
if(typeof event.title !== 'undefined')
$('#block-materio-page-title-materio-page-title h1').html(event.title);
};
function onListEdited(event){
trace('MaterioPageTitle :: onListEdited', event);
// this is for refreshing page title when list title was just edited AND this list is the cirreunt list
if($("#materio-page-title ."+event.name).length)
$('a.open-list.'+event.name).eq(0).trigger('click');
};
init();
};
$(document).ready(function() {
var materiopagetitle = new MaterioPageTitle();
});
})(jQuery);

View File

@ -0,0 +1,44 @@
// @codekit-prepend "gui.js"
// @koala-prepend "gui.js"
(function($) {
MaterioPageTitle = function(){
function init(){
$(document)
.bind('materio-page-title-refresh-block', onRefreshBlock)
.bind('list-edited', onListEdited);
};
function onRefreshBlock(event){
trace('MaterioPageTitle :: onRefreshBlock', event);
// var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_page_title/refresh/block';
// $.getJSON(url, function(json){
// trace('page title json', json);
// $('#block-materio-page-title-materio-page-title').replaceWith(json.block);
// });
if(typeof event.title !== 'undefined')
$('#block-materio-page-title-materio-page-title h1').html(event.title);
};
function onListEdited(event){
trace('MaterioPageTitle :: onListEdited', event);
// this is for refreshing page title when list title was just edited AND this list is the cirreunt list
if($("#materio-page-title ."+event.name).length)
$('a.open-list.'+event.name).eq(0).trigger('click');
};
init();
};
$(document).ready(function() {
var materiopagetitle = new MaterioPageTitle();
});
})(jQuery);

View File

@ -0,0 +1,341 @@
// @codekit-prepend "gui.js"
// @koala-prepend "gui_ck_fw/gui.js"
(function($) {
MaterioSearchApiAjax = function(){
var _isloadingresults = false;
var _$content = $('#content');
// TODO: define $content by module settings
/**
* init()
*/
function init(){
//trace('init MaterioSearchApiAjax');
initSearchAjax();
initViewMode();
};
/**
* searchAjax
*/
function initSearchAjax(){
// trace('initSearchAjax');
$('#materio-search-api-search-form').bind('submit', function(event) {
// trace('search submited', event);
// var $this = $(this);
setTimeout(function(){
loadResults(getSearchKeys());
},10);
return false;
});
// /!\ AUTOCOMPLETE SELECT EVENT need a patch http://drupal.org/node/365241#comment-5374686
$("#edit-searchfield")
.bind('autocompleteSelect', function(event) {
// $(this).parents('.form').trigger('submit');
setTimeout(function(){
loadResults(getSearchKeys(), "taxonomy");
},10);
})
.bind('focus', function(event){
$(this).select();
});
$(document)
.bind('theme-ready', onThemeReady)
.bind('init-scroller-pager', onInitScrollerPager)
.bind('load-scroller-pager', onLoadScrollerPager)
.bind('view-mode-changed', onViewModeChanged)
.bind('history-state-change', onHistoryStateChange);
};
function onThemeReady(event){
// trace('MaterioSearchApiAjax :: onThemeReady');
if( isActuality() || isExplore() ){
$.event.trigger({
type : 'resultschanged',
container : isActuality() ? '#content .actuality-items' : '#content .search-results'
});
}
};
function getSearchKeys(){
return $('#materio-search-api-search-form').find('input[name*="searchfield"]').val();
};
function loadResults(keys, searchmode){
//trace('keys', keys);
if(keys !== undefined && keys !== '' && keys.length >= 2){
keys = keys.replace('/', ' ');
// define mode (between full text or only term selected on autocompletion)
searchmode = searchmode || "fulltext";
// record the "node type filter" form item
var types = {}, stringTypes = [];
$('#edit-bundles-filter', '#materio-search-api-search-form').find('input[type*="checkbox"]').each(function(i){
$this = $(this);
if ( $this.attr('checked') )
stringTypes.push($this.val());
types[$this.val()] = $this.attr('checked');
});
//trace('types', types);
if(!_isloadingresults){
$.event.trigger('loading-content');
_isloadingresults = true;
$('#materio-search-api-search-form').addClass('loading');
// trace('window.location.href',window.location.href);
// TODO: record ajax path in a variable from materio_search_api_ajax_init
$.getJSON(Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/search/',
{'types':types,'current_path':document.location.href, 'keys':keys, 'searchmode':searchmode},
function(json){
//trace('json', json);
// google analytics
$.event.trigger({
type : "record-stat",
categorie : 'Search',
action : keys,
label : 'filters : '+ stringTypes.join(' ,'),
value : json.count
});
if(json.redirect){
window.location = json.redirect;
}else{
$.event.trigger('loaded-content');
_isloadingresults = false;
$('#materio-search-api-search-form').removeClass('loading');
changeContent(json);
}
});
}
}
};
function loadActuality(){
if(!_isloadingresults){
$.event.trigger('loading-content');
_isloadingresults = true;
$('#materio-search-api-search-form').addClass('loading');
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/actuality';
$.getJSON(url,
function(json){
//trace('json', json);
$.event.trigger('loaded-content');
_isloadingresults = false;
$('#materio-search-api-search-form').removeClass('loading');
changeContent(json);
});
}
};
function changeContent(json){
//trace('MaterioSearchApiAjax changeContent | json', json);
if(json.returned){
$.event.trigger('loaded-content');
$('.inner-content',_$content).html(json.returned).find('ul.pager').hide();
triggerContentChanged();
}else{
//trace('no results');
}
$.event.trigger({
type : 'new-history-page',
path : Drupal.settings.basePath + Drupal.settings.pathPrefix + json.path,
title : json.title,
content : json.returned
});
for (language in Drupal.settings.materio_search_api_ajax.languages) {
var l = Drupal.settings.materio_search_api_ajax.languages[language];
$('#block-locale-language li.'+language+' a').attr('href', Drupal.settings.basePath + l.prefix+'/' + json.search_path + '/' + json.keys)
};
};
function triggerContentChanged(){
//trace('MaterioSearchApiAjax :: triggerContentChanged');
$.event.trigger({
type : 'resultschanged',
container : '#content .search-results, #content .actuality-items'
});
};
function onInitScrollerPager(event){
// trace("onInitScrollerPager");
if(isActuality() || isExplore())
event.pager.hide();
};
function onLoadScrollerPager(event){
// trace("onLoadScrollerPager");
if(!_isloadingresults){
if (isExplore())
loadNextResultsPage(event.href);
if(isActuality())
loadNextActualityPage(event.href);
}
};
function loadNextResultsPage(href){
// trace('loadNextResultsPage');
var keys = href.match(/explore\/([^\/|\?]+)/);
var page = href.match(/\?page=([0-9]+)/);
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/search/'+page[1];
loadNextPage(url, keys[1], $('.materiobase-results', _$content), '.search-results');
};
function loadNextActualityPage(href){
// trace('loadNextActualityPage');
var page = href.match(/\?page=([0-9]+)/);
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/actuality/'+page[1];
loadNextPage(url, '', $('.materiobase-actuality', _$content), '.actuality-items');
};
function loadNextPage(url, keys, $container, target){
// trace('MaterioSearchApiAjax :: loadNextPage()');
_isloadingresults = true;
$container.addClass('loading');
$.getJSON(url, {'keys':keys}, function(json){
//trace('json', json);
$container.removeClass('loading');
addNextpage(json, target);
// addNextpageItemByItem($(json.return), target);
});
};
function addNextpage(json, container_class){
// trace('json',json);
if(json){
var $newcontent = $(json.returned),
$newitems = $(container_class, $newcontent).children('article'), //.addClass('just-added'),
$newpager = $('ul.pager', $newcontent);
$(container_class, _$content).append($newitems);
$('ul.pager', _$content).replaceWith($newpager.hide());
// TODO: animation, this should be on theme side
$(container_class, _$content).children('.just-added').each(function(i){
var $this = $(this);
setTimeout(function(){
$this.removeClass('just-added');
}, 150*i);
});
$.event.trigger({
type : 'resultscompleted',
container : $(container_class, _$content)
});
}
_isloadingresults = false;
};
// TEST not used
function addNextpageItemByItem($newcontent, container_class){
//trace('MaterioSearchApiAjax :: addNextpageItemByItem()');
$('ul.pager', _$content).remove();
$(container_class, _$content).append($(container_class, $newcontent).children('article').eq(0));
if($(container_class, $newcontent).children('article').length){
setTimeout(function(){
addNextpageItemByItem($newcontent, container_class);
}, 200);
}else{
_isloadingresults = false;
$('ul.pager', _$content).replaceWith($('ul.pager', $newcontent).hide());
$.event.trigger({
type : 'resultscompleted',
container : $(container_class, _$content)
});
}
};
/**
* viewmode
*/
function initViewMode(){
$('.viewmode-link').click(function(event){
event.preventDefault();
if(!$(this).is('.active')){
$(this).trigger({type:'vm-clicked'});
changeViewMode($(this).attr('rel'), $(this));
}else{
$(this).trigger({type:'vm-clicked-active'});
}
return false;
});
};
function changeViewMode(vm, $btn){
if(!_isloadingresults){
_isloadingresults = true;
$.getJSON(Drupal.settings.basePath+'materio_search_api_ajax/viewmode/change/'+vm, function(json){
//trace('viewmode json', json);
_isloadingresults = false;
if (json.statut == "saved"){
// google analytics
$.event.trigger({
type : "record-stat",
categorie : 'Viewmode',
action : vm,
label : isActuality() ? 'Actualities' : 'Search results'
});
$.event.trigger('view-mode-changed');
$('.viewmode-link, .viewmode-link i').removeClass('active');
$btn.addClass('active').find('i').addClass('active');
}
});
}
};
function onViewModeChanged(event){
if (isExplore())
loadResults(getSearchKeys());
if(isActuality())
loadActuality();
};
/**
* history
*/
function onHistoryStateChange(event){
if(isExplore() || isActuality())
triggerContentChanged();
// TODO: pushstate trogger state change, so we have a retriggerring here on loading new results … how to avoid this
};
/**
* helpers
*/
function isExplore(){
return $('.search-results', '#content').length;
};
function isActuality(){
return $('.actuality-items', '#content').length;
};
init();
};
$(document).ready(function() {
var materiosearchapiajax = new MaterioSearchApiAjax();
});
})(jQuery);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,161 @@
// @codekit-prepend "gui.js"
// @koala-prepend "gui_ck_fw/gui.js"
(function($) {
MaterioUser = function(){
var _isAdhesion = $('body').is('.page-node-11187') || $('body').is('.page-node-11186');
function init() {
//trace('MaterioUser init compile test 3');
if(_isAdhesion)
initAdhesion();
};
function initAdhesion(){
// trace('initAdhesion');
$('.get-link a').bind('click', function(event) {
// trace('get-link click');
// do not show the registration form if already logged-in
if($('body').is('.logged-in'))
return true;
// else show the ajaxified registration form
event.preventDefault();
var $this = $(this),
href = $this.attr("href"),
destination = href.match('/\?destination=([^,]+)');
destination = "/" + destination[1].replace('%23', '#');
destination = destination.replace('//', '/');
// trace('destination', destination);
if($this.parents('.gratos').size()){
loadRegisterBlock(destination);
}else{
loadLoginAndRegisterBlock(destination);
}
return false;
});
};
function loadRegisterBlock (destination) {
// trace("loadRegisterBlock :: dest = "+destination);
$.getJSON(Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_user/registerblock', function(json){formLoaded(json, destination);});
}
function loadLoginAndRegisterBlock(destination){
// trace('loadRegistrationBlock :: dest = '+destination);
$.getJSON(Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_user/loginandregisterblock', function(json){formLoaded(json, destination);});
};
function formLoaded(json, destination){
//trace('formLoaded | json', json);
var $modal = $('<div>').addClass('modal-content').append(json.block);
var id,label, description;
$('input.form-text', $modal).each(function(i) {
id = $(this).attr('id');
label = $('label[for='+id+']').hide().text();
description = $(this).parent().find('.description').hide().text();
$(this).attr('placeholder', label).attr('title', description);
});
// $('.homepage-textfield', $modal).hide();
$('body').append($('<div>').addClass('modal-wrapper').append($modal));
$('.modal-wrapper').bind('click', function(event) {
$(this).remove();
});
$('.modal-content').bind('click', function(event) {
event.stopPropagation();
});
// doesn't work
// Drupal.attachBehaviors('bodi>.modal-wrapper');
$.event.trigger('ajax-register-block-loaded');
$("#user-register-form #edit-submit, #user-register-form #edit-submit--2", $modal).click(function(event){
event.preventDefault();
// disable submit button to avoid duplicate user creation
// console.log('click', this);
$(this).attr('disabled', 'true');
$.ajax({
type: 'POST',
dataType:'json',
url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/register/submit",
data: $('#user-register-form', $modal).serialize(),
success: function(data) { onUserLoginRegisterSubmit($('#user-register-form'), data, destination);},
error: function(jqXHR, textStatus, errorThrown) { trace('error : '+textStatus+' | '+errorThrown); }
});
return false;
});
$("#user-login #edit-submit", $modal).click(function(event){
event.preventDefault();
$.ajax({
type: 'POST',
dataType:'json',
url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/login/submit",
data: $('#user-login', $modal).serialize(),
success: function(data){ onUserLoginRegisterSubmit($('#user-login'), data, destination); },
error: function(jqXHR, textStatus, errorThrown) { trace('error : '+textStatus+' | '+errorThrown); }
});
return false;
});
// google analytics
// $.event.trigger({
// type : "record-stat",
// categorie : 'Search',
// action : keys,
// label : 'filters : '+ stringTypes.join(' ,'),
// value : json.count
// });
};
function onUserLoginRegisterSubmit($form, data, destination){
// console.log('data', data);
cleanModalErrors();
if(data.errors != null){
for(field in data.errors){
$('input[name='+field+']', $form).addClass('error');
$form.prepend($('<div>').addClass('message-error').html(data.errors[field]));
}
(function($form){
setTimeout(function(){
console.log('enabled');
$('input[type=submit]', $form).removeAttr('disabled');
}, 0.5*1000);
})($form);
}else{
// trace('destination = '+destination);
window.location.pathname = destination;
}
};
function cleanModalErrors() {
$('.message-error', '.modal-content').remove();
$('input', '.modal-content').removeClass('error');
}
init();
};
$(document).ready(function() {
var materiouser = new MaterioUser();
});
})(jQuery);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,25 @@
name = Materio Admin
description = "Materio admin module"
; Core version (required)
core = 7.x
; Package name (see http://drupal.org/node/542202 for a list of names)
package = Materio
; PHP version requirement (optional)
; php = 5.2
; Loadable code files
; Module dependencies
; dependencies[] = user
;dependencies[] = logintoboggan
;dependencies[] = simplenews
;dependencies[] = rules
; Configuration page
; configure = admin/config/materiobasemod
; For further information about configuration options, see
; - http://drupal.org/node/542202

View File

@ -0,0 +1,212 @@
<?php
/**
* Implements hook_permission().
*/
function materio_admin_permission() {
return array(
'access default users list' => array(
'title' => t('Access default users list'),
'description' => t('Access default users list.'),
),
'access default UC roles expiration list' => array(
'title' => t('access default UC roles expiration list'),
'description' => t('access default UC roles expiration list.'),
),
'access duplicate mails list' => array(
'title' => t('access duplicate mails list'),
'description' => t('access duplicate mails list.'),
),
);
}
/**
* Implements hook_menu().
*/
function materio_admin_menu() {
$items['admin/users/duplicatemails'] = array(
'title' => "Duplicate mails",
'page callback' => 'materio_duplicatemails',
'access callback' => 'user_access',
'access arguments' => array('access duplicate mails list'),
'type' => MENU_LOCAL_TASK
);
if(module_exists('simplenews')){
$cats = simplenews_category_list();
// dsm($cats, 'cats');
foreach ($cats as $tid => $name) {
// $items['node/%node/simplenews'] = array(
// 'title' => 'Newsletter',
// 'type' => MENU_LOCAL_TASK,
// 'access callback' => 'simplenews_node_tab_access',
// 'access arguments' => array(1),
// 'page callback' => 'simplenews_node_tab_page',
// 'page arguments' => array(1),
// 'context' => MENU_LOCAL_TASK,
// 'file' => 'includes/simplenews.admin.inc',
// 'weight' => 2,
// );
$items['node/add/simplenews/'.$tid] = array(
'title' => $name,
'title callback' => 'check_plain',
'page callback' => 'node_add',
'page arguments' => array('simplenews'),
'access callback' => 'node_access',
'access arguments' => array('create', 'simplenews'),
'file path' => drupal_get_path('module', 'node'),
'file' => 'node.pages.inc',
);
}
}
return $items;
}
function materio_duplicatemails(){
$mails = db_query('SELECT mail FROM {users} GROUP BY mail HAVING count(mail) > 1')->fetchCol();
// Bail out early if there are no duplicates.
if (!$mails) {
return t('All accounts have unique email addresses.');
}
// Grab all the user data for accounts with addresses identified as
// duplicates. This is a little convoluted, but it lets us grab all the user
// data in one shot.
$uids = db_select('users', 'u')
->fields('u', array('uid'))
->condition('mail', $mails, 'IN')
->orderBy('access', 'DESC')
->execute()
->fetchCol();
$duplicate_users = user_load_multiple($uids);
$duplicate_mails = array();
foreach ($duplicate_users as $duplicate_user) {
$duplicate_mails[$duplicate_user->mail][] = $duplicate_user;
}
// Turn the data we've got into markup.
$output = t('Accounts with duplicate email address:') . '<br />';
$output = "<ul>";
foreach ($duplicate_mails as $mail => $users) {
$output .= "<li> <strong>$mail</strong> : <br />";
$accounts = array();
foreach ($users as $duplicate_user) {
$accounts[] = l($duplicate_user->name, "user/{$duplicate_user->uid}") . ' ('. date('Y-m-d', $duplicate_user->access) .')';
}
$output .= implode(', ', $accounts);
$output .= '</li>';
}
$output .= "</ul>";
return $output;
}
/**
* Implements hook_menu_alter().
*/
function materio_admin_menu_alter(&$items){
// dsm($items, 'menu alter items');
if(isset($items['admin/people'])){
$items['admin/people']['access arguments'] = array('access default users list');
// dsm($items['admin/people']);
}
if(isset($items['admin/people/expiration'])){
$items['admin/people/expiration']['access arguments'] = array('access default UC roles expiration list');
// dsm($items['admin/people/expiration']);
}
# deactivate default home page
$items['node']['access callback'] = FALSE;
// if(isset($items['admin/content/add/simplenews'])){
// delete($items['admin/content/add/simplenews']);
// $cats = simplenews_category_list();
// dsm($cats, 'cats');
// foreach ($cats as $tid => $name) {
// $items['admin/content/add/simplenews/'.$tid]
// }
// }
}
/**
* Implements hook_menu_local_tasks_alter().
*/
function materio_admin_menu_local_tasks_alter(&$data, $router_item, $root_path) {
if ($root_path == 'admin/people/simplenews') {
$item = menu_get_item('admin/content/simplenews');
if ($item['access']) {
$item['title'] = 'Go to '.$item['title'];
$data['actions']['output'][] = array(
'#theme' => 'menu_local_task',
'#link' => $item,
);
}
}
if ($root_path == 'admin/content/simplenews') {
$cats = simplenews_category_list();
foreach ($cats as $tid => $name) {
$item = menu_get_item('node/add/simplenews/'.$tid);
$item['title'] = 'Add new '.$name;
if ($item['access']) {
$data['actions']['output'][] = array(
'#theme' => 'menu_local_task',
'#link' => $item,
);
}
}
$item = menu_get_item('admin/people/simplenews');
if ($item['access']) {
$item['title'] = 'Go to '.$item['title'];
$data['actions']['output'][] = array(
'#theme' => 'menu_local_task',
'#link' => $item,
);
}
}
}
/**
* Implements hook_form_alter().
*/
function materio_admin_form_simplenews_node_form_alter(&$form, &$form_state, $form_id) {
// dsm($form_id, '$form_id');
// dsm($form_state, '$form_state');
// dsm($form, '$form');
// dsm($_GET, 'GET');
if(!$form['nid']['#value']){
$cats = simplenews_category_list();
$cats_tids = array_keys($cats);
$q = parse_url($_GET['q']);
$cat = array_pop(explode('/', $q['path']));
// dsm($cat, 'cat');
if(in_array($cat, $cats_tids)){
// prepopulate type of news
$form['field_simplenews_term']['und']['#default_value'] = $cat;
$form['field_simplenews_term']['und']['#disabled'] = true;
// change default template regarding type of news
$form['body']['und'][0]['#default_value'] = materio_admin_getSimplenewsNodeBodyTemplate($cat);
}
}else{
$form['field_simplenews_term']['und']['#disabled'] = true;
}
$form['body']['und'][0]['#rows'] = 50;
}
function materio_admin_getSimplenewsNodeBodyTemplate($cat){
return file_get_contents(drupal_get_path('module', 'materio_admin').'/templates/simplenews_'.$cat.'_node.html');
}

View File

@ -0,0 +1,29 @@
name = Materio Didactique
description = "Materio Didactique module"
; Core version (required)
core = 7.x
; Package name (see http://drupal.org/node/542202 for a list of names)
package = Materio
; PHP version requirement (optional)
; php = 5.2
; Loadable code files
;files[] = materio_didactique.theme.inc
;files[] = materio_didactique.forms.inc
files[] = materio_didactique.pages.inc
;files[] = materio_didactique.admin.inc
files[] = materio_didactique.module
; Module dependencies
;dependencies[] = taxonomy
;dependencies[] = search_api
;dependencies[] = search_api_solr
; Configuration page
; configure = admin/config/materiobasemod
; For further information about configuration options, see
; - http://drupal.org/node/542202

View File

@ -0,0 +1,117 @@
<?php
/**
* Implements hook_permission().
*/
function materio_didactique_permission() {
return array(
'view materio didactique home block' => array(
'title' => t('view materio didactique home block'),
'description' => t(''),
),
'access materio didactique page' => array(
'title' => t('access materio didactique page'),
'description' => t(''),
),
);
}
/**
* Implements hook_menu().
*/
function materio_didactique_menu() {
$items['whoweare'] = array(
'title' => 'Who we are',
'page callback' => 'materio_didactique_get_page',
// 'page arguments' => array(),
'access arguments' => array('access materio didactique page'),
'type' => MENU_CALLBACK,
'file' => 'materio_didactique.pages.inc',
);
return $items;
}
/**
* Implements hook_block_info().
*/
function materio_didactique_block_info() {
$blocks['materio_didactique_home'] = array(
'info' => t('Materio didactique home block'),
'cache' => DRUPAL_NO_CACHE
);
return $blocks;
}
/**
* Implements hook_block_view().
*/
function materio_didactique_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'materio_didactique_home':
if(user_access('view materio didactique home block')){
$query = new EntityFieldQuery;
$query
->entityCondition('entity_type', 'node')
->propertyCondition('status', 1)
->entityCondition('bundle', array('didactique'))
->fieldCondition('field_displayed_in_home', 'value', 1)
->fieldOrderBy('field_weight', 'value', 'ASC');
$result = $query->execute();
// dsm($result, '$result');
if (isset($result['node'])) {
$block['subject'] = t('Didactique home block');
$block['content'] = theme('materio_didactique_home_block', array('items' => $result['node']));
}
}
break;
}
return $block;
}
/**
* Implements hook_theme().
*/
function materio_didactique_theme($existing, $type, $theme, $path) {
return array(
'materio_didactique_home_block' => array(
'arguments' => array('items'=>NULL),
'template' => 'materio-didactique-home-block',
'path' => drupal_get_path('module', 'materio_didactique').'/templates',
),
'materio_didactique_page' => array(
'arguments' => array('items'=>array()),
'template' => 'materio-didactique-page',
'path' => drupal_get_path('module', 'materio_didactique').'/templates',
)
);
}
function template_preprocess_materio_didactique_home_block(&$vars){
// dsm($vars, 'template_preprocess_materio_didactique_home_block | $vars');
$items = array();
foreach ($vars['items'] as $nid => $item) {
$items[] = node_load($nid);
}
$vars['items'] = $items;
}
function template_preprocess_materio_didactique_page(&$vars){
// dsm($vars, 'template_preprocess_materio_didactique_page | $vars');
$items = array();
foreach ($vars['items'] as $nid => $item) {
$items[] = node_load($nid);
}
$vars['items'] = $items;
}

View File

@ -0,0 +1,17 @@
<?php
function materio_didactique_get_page(){
$query = new EntityFieldQuery;
$query
->entityCondition('entity_type', 'node')
->propertyCondition('status', 1)
->entityCondition('bundle', array('didactique'))
->fieldCondition('field_displayed_in_whoweare', 'value', 1)
->fieldOrderBy('field_weight', 'value', 'ASC');
$result = $query->execute();
// dsm($result, '$result');
return theme('materio_didactique_page', array('items' => $result['node']));
}

View File

@ -0,0 +1,23 @@
name = Materio Display
description = "Materio display module (permissions, ...)"
; Core version (required)
core = 7.x
; Package name (see http://drupal.org/node/542202 for a list of names)
package = Materio
; PHP version requirement (optional)
; php = 5.2
; Loadable code files
; files[] = materio_ctools_automodal.module
; Module dependencies
; dependencies[] = user
; Configuration page
; configure = admin/config/materiobasemod
; For further information about configuration options, see
; - http://drupal.org/node/542202

View File

@ -0,0 +1,58 @@
<?php
/**
* Implements hook_init().
*/
// function materio_user_init() {
// drupal_add_js(drupal_get_path('module', 'materio_user').'/js/materio_user.min.js');
// }
/**
* Implements hook_permission().
*/
function materio_display_permission() {
return array(
'view full materiau description' => array(
'title' => t('view full materiau description'),
'description' => t('view full materiau description'),
),
);
}
/**
* Implements hook_preprocess().
*/
function materio_display_preprocess_field(&$vars, $hook) {
// dsm($vars);
$element = $vars['element'];
if($element['#field_name'] == 'field_description'){
// dsm($vars);
if(!user_access('view full materiau description')){
$value = $element['#items'][0]['value'];
switch ($element['#view_mode']) {
case 'cardbig':
case 'cardfull':
$limit = 210;
break;
default:
$limit = 130;
break;
}
$summary = truncate_utf8($value, $limit, TRUE, TRUE);
$summary .= '<div class="upgrade"><p>'
. t("In order to access full description, information about manufacturers and more, you need to upgrade your account.")
. l(t("Pricing"), 'node/11187')
. '</p></div>';
// dsm($summary);
$vars['items'][0]['#markup'] = $summary;
}
}
}

View File

@ -0,0 +1,7 @@
name = Materio Flag
description = Provides bookmark flag (and maybe folders).
core = 7.x
dependencies[] = flag
dependencies[] = flag_lists
package = Materio

View File

@ -0,0 +1,72 @@
<?php
/**
* @file
* The Flag Bookmark module install hooks.
*/
/**
* Implements hook_install().
*/
function materio_flag_install() {
// Everything is handled by hook_enable().
}
/**
* Implements hook_enable().
*
* We create the demonstration flag on enable, so hook implementations in flag
* module will fire correctly, as the APIs are not available on install.
*/
function materio_flag_enable() {
// Load the flag API in case we want to use it when enabling.
include_once(drupal_get_path('module', 'flag') . '/flag.module');
if (!flag_get_flags()) {
// Install a demonstration flag only if no flag exists. This is to prevent
// a case where a disables and enables the module, and the demonstration
// flag is overwritten or re-created.
$flag = flag_flag::factory_by_entity_type('node');
$configuration = array(
'name' => 'bookmarks',
'global' => 0,
'show_on_page' => 1,
'show_on_teaser' => 0,
'show_on_form' => 0,
// The following UI labels aren't wrapped in t() because they are written
// to the DB in English. They are passed to t() later, thus allowing for
// multilingual sites.
'title' => 'Bookmarks',
'flag_short' => 'Bookmark this',
'flag_long' => 'Add this post to your bookmarks',
'flag_message' => 'This post has been added to your bookmarks',
'unflag_short' => 'Unbookmark this',
'unflag_long' => 'Remove this post from your bookmarks',
'unflag_message' => 'This post has been removed from your bookmarks',
'types' => _materio_flag_install_get_suggested_node_types(),
);
$flag->form_input($configuration);
$flag->save();
// Clear the flag cache so the new permission is seen by core.
drupal_static_reset('flag_get_flags');
// Grant permissions.
$permissions = array('flag bookmarks', 'unflag bookmarks');
user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, $permissions);
}
}
/**
* Returns some node types to which the demonstration 'bookmarks' flag will apply.
*/
function _materio_flag_install_get_suggested_node_types() {
$preferred = array('page', 'article', 'story', 'forum', 'blog');
$existing = array_intersect($preferred, array_keys(node_type_get_types()));
if (!$existing) {
// As a last resort, take the first preference.
return array($preferred[0]);
}
return $existing;
}

View File

@ -0,0 +1,502 @@
<?php
/**
* @file
* The Flag bookmark module.
*
* This module creates a default Flag when enabled.
*
*/
/**
* Implements hook_permission().
*/
function materio_flag_permission() {
return array(
'access mybookmarks block' => array(
'title' => t('Show my bookmarks block'),
'description' => t('access own bookmarks block'),
),
);
}
/**
* Implements hook_menu().
*/
function materio_flag_menu() {
$items = array();
$base = array(
'type' => MENU_CALLBACK,
'file' => 'materio_flag.pages.inc',
);
$items['materioflag/refresh/block/bookmarks'] = $base+array(
'access arguments' => array('flag bookmarks'),
'page callback' => 'materio_flag_refresh_block',
'page arguments' => array(3),
);
$items['bookmarks'] = $base+array(
'access arguments' => array('flag bookmarks'),
'page callback' => 'materio_flag_user_bookmarks',
'page arguments' => array(),
);
$items['materioflag/refresh/block/lists'] = $base+array(
'access arguments' => array('create flag lists'),
'page callback' => 'materio_flag_refresh_block',
'page arguments' => array(3),
);
$items['materioflag/createlist/form/%'] = $base+array(
'access arguments' => array('create flag lists'),
'access callback' => 'user_access',
'page callback' => 'materio_flag_createlist_form',
'page arguments' => array(3),
);
$items['materioflag/editlistform/%/%'] = $base+array(
'access arguments' => array('create flag lists'),
'access callback' => 'user_access',
'page callback' => 'materio_flag_editlist_form',
'page arguments' => array(2,3),
);
$items['materioflag/editlist/%/%'] = $base+array(
'access arguments' => array('create flag lists'),
'access callback' => 'user_access',
'page callback' => 'materio_flag_edit_list',
'page arguments' => array(2,3),
);
$items['materioflag/deletelist/%'] = $base+array(
'access arguments' => array('create flag lists'),
'access callback' => 'user_access',
'page callback' => 'materio_flag_delete_list',
'page arguments' => array(2,3),
);
$items['materioflag/nodelinks'] = $base+array(
'access arguments' => array('create flag lists'),
'access callback' => 'user_access',
'page callback' => 'materio_flag_nodelinks',
// 'page arguments' => array(3),
);
$items['lists/%'] = $base+array(
'access arguments' => array('view flag lists'),
'access callback' => 'user_access',
'page callback' => 'materio_flag_user_lists',
'page arguments' => array(1),
);
$items['materioflag/ajax/list/%'] = $base+array(
'page callback' => 'materio_flag_ajax_list',
'access callback' => 'materio_access_ajax_flags',
'page arguments' => array(3, 4),
);
return $items;
}
function materio_access_ajax_flags(){
return user_access('create flag lists') || user_access('flag bookmarks');
}
/**
* Implements hook_menu_alter().
*/
function materio_flag_menu_alter(&$items) {
// Example - disable the page at node/add
/*
*$items['node/add']['access callback'] = FALSE;
*/
// disable tabs on user page
$items['user/%user/flags/lists']['access callback'] = false;
$items['user/%user/flags/lists/%']['access callback'] = false;
}
/**
* Implements hook_block_info().
*/
function materio_flag_block_info() {
$blocks['materio_flag_mybookmarks'] = array(
'info' => t('My bookmarks'),
'cache' => DRUPAL_NO_CACHE
);
$blocks['materio_flag_mylists'] = array(
'info' => t('My Materio flag lists'),
'cache' => DRUPAL_NO_CACHE
);
$blocks['materio_flag_mylists_nav'] = array(
'info' => t('My Materio flag lists navigation'),
'cache' => DRUPAL_NO_CACHE
);
return $blocks;
}
/**
* Implements hook_block_view().
*/
function materio_flag_block_view($delta = '') {
global $user;
$block = array();
switch ($delta) {
case 'materio_flag_mybookmarks':
if(user_access('access mybookmarks block')){
$userflags = flag_get_user_flags('node');
//dsm($userflags, 'userflags');
if(isset($userflags['bookmarks'])){
$userbookmarks = array();
foreach ($userflags['bookmarks'] as $nid => $flag) {
$userbookmarks[] = node_load($nid);
}
// TODO: put this title generation on a theme function
$subject = '<span class="listname">'.t('My bookmarks (@len) ', array("@len"=>count($userbookmarks))).'</span>';
$block['subject'] = $subject . l('<i class="icon-resize-full"></i>', 'bookmarks', array('html'=>true, 'attributes' => array('class' => array('open-list')),)); //
$block['content'] = theme('materio_flag_mybookmarks_block', array("bookmarks"=>$userbookmarks, "viewmode"=>"bookmark"));
}else{
$block['subject'] = t('My bookmarks');
$block['content'] = t('No bookmarks yet. Add bookmarks on clicking on results star');
}
drupal_add_js(drupal_get_path('module', 'materio_flag').'/js/materio_flag.min.js');
}
break;
case 'materio_flag_mylists':
if(user_access('create flag lists')){
$flags = flag_lists_get_user_flags(NULL, $user);
// $userflags = flag_get_user_flags('node');
// dsm($userflags, 'userflags');
// dsm($flags, 'flags');
foreach ($flags as $name => $flag) {
$flag->path = url('lists/'.$flag->fid);
$flaged_content = flag_lists_get_flagged_content($flag->fid, $user->uid);
// dsm($flaged_content, 'flaged_content');
$fcn = array();
foreach ($flaged_content as $entity) {
if($entity->entity_type == 'node'){
$node = node_load($entity->entity_id);
// dsm($node, 'node');
// $node->flag_names[] = $name;
$fcn[] = $node;
}
}
$lists[$name] = array(
'list' => $flag,
'content' => $fcn,
);
}
if(isset($lists)){
// $block['subject'] = t('My !listname'.'s', array('!listname'=>t(variable_get('flag_lists_name', 'list'))));
$block['subject'] = t('My '.variable_get('flag_lists_name', 'list').'s');
$block['content'] = theme('materio_flag_mylists_block', array("lists"=>$lists, "viewmode"=>"bookmark"));
// $block['content'] = theme('flag_lists_user_page', array('uid' => $user->uid));
}else{
$block['subject'] = t('My '. variable_get('flag_lists_name', 'list') .'s');
$block['content'] = t('No !listname yet. Add !listname on clicking on results star', array('!listname'=>variable_get('flag_lists_name', 'list')));
}
drupal_add_js(drupal_get_path('module', 'materio_flag').'/js/materio_flag.min.js');
}
break;
case 'materio_flag_mylists_nav':
if(user_access('create flag lists')){
$flags = flag_lists_get_user_flags(NULL, $user);
foreach ($flags as $name => $flag) {
$flaged_content = flag_lists_get_flagged_content($flag->fid, $user->uid);
$flag->flaged_content = $flaged_content;
$flags[$name] = $flag;
}
// if($flags){
// $block['subject'] = t('My !listname'.'s', array('!listname'=>variable_get('flag_lists_name', 'list')));
$block['subject'] = t('My '.variable_get('flag_lists_name', 'list').'s');
$block['content'] = theme('materio_flag_mylists_nav_block', array("flags"=>$flags));
// $block['content'] = theme('flag_lists_user_page', array('uid' => $user->uid));
// }
# what happend if no flags yet
// else{
// $block['subject'] = t('My '.variable_get('flag_lists_name', 'list').'s');
// // $block['content'] = t('No !listname yet. Add !listname on clicking on results star', array('!listname'=>variable_get('flag_lists_name', 'list')));
// }
}
break;
}
return $block;
}
/**
* Implements hook_entity_info_alter().
*/
function materio_flag_entity_info_alter(&$entity_info) {
$entity_info['node']['view modes']['bookmark'] = array(
'label' => t('Bookmark'),
'custom settings' => TRUE,
);
}
/**
* Implements hook_entity_view().
*
* Note this is broken for taxonomy terms. @see http://drupal.org/node/1067120
*/
function materio_flag_entity_view($entity, $type, $view_mode, $langcode) {
if($type == 'node'){
if(user_access('create flag lists') && $view_mode != 'print'){
$entity->content['flaglistslinks'] = materio_flag_get_entity_links($entity, $type, $view_mode);
drupal_add_css(drupal_get_path('module', 'flag') . '/theme/flag.css');
drupal_add_js(drupal_get_path('module', 'flag') . '/theme/flag.js');
// Do we have a list template for this node type, or are we s
if (flag_lists_template_exists($entity->type)) {
global $user;
if ($flags = flag_lists_get_user_flags($entity->type, $user)) {
foreach ($flags as $flag) {
// dsm($flag, 'flag');
if ( ($flag->module == 'flag_lists' && _flag_lists_is_flagged($flag, $entity->nid, $user->uid, 0)) || $flag->is_flagged($entity->nid) ) {
$entity->flags[] = $flag;
}
}
}
}
}
}
}
function materio_flag_get_entity_links($entity, $type, $view_mode = null){
// dsm($entity, 'entity');
// Do we have a list template for this node type, or are we s
if (!flag_lists_template_exists($entity->type)) {
return;
}
global $user;
$links = array();
# if flag name is provided we are on flaglists content list (block mylists)
if($view_mode == 'bookmark'){
// TODO: define view mode in settings
// if (isset($entity->flag_names) && $flags = flag_lists_get_user_flags($entity->type, $user)) {
// // dsm($flags, 'flags');
// // TODO: limit flag link by current flag list
// foreach ($flags as $flag) {
// //dsm($flag->name, 'flag');
// if(in_array($flag->name, $entity->flag_names)){
// if ($flag->module == 'flag_lists') {
// $action = _flag_lists_is_flagged($flag, $entity->nid, $user->uid, 0) ? 'unflag' : 'flag';
// } else {
// $action = $flag->is_flagged($entity->nid) ? 'unflag' : 'flag';
// }
// $flag->module = 'materio_flag';
// $link = $flag->theme($action, $entity->nid);
// // If it's a list, fix the link.
// if ($flag->module == 'flag_lists') {
// flag_lists_fix_link($link, $action);
// }
// $items[] = array(
// 'data' => $link,
// 'class' => array('flag-lists-link', $action.'-action'),
// );
// // array_splice($entity->flag_names, array_search($flag->name, $entity->flag_names), 1);
// // dsm($entity->flag_names, 'entity->flag_name');
// // break;
// }
// }
// }
#normal display
}else{
if ($flags = flag_lists_get_user_flags($entity->type, $user)) {
// dsm($flags, 'flags');
// Build the list of lists for this node.
foreach ($flags as $flag) {
// dsm($flag, 'flag');
if ($flag->module == 'flag_lists') {
$action = _flag_lists_is_flagged($flag, $entity->nid, $user->uid, 0) ? 'unflag' : 'flag';
}
else {
$action = $flag->is_flagged($entity->nid) ? 'unflag' : 'flag';;
}
$link = $flag->theme($action, $entity->nid);
// If it's a list, fix the link.
if ($flag->module == 'flag_lists') {
flag_lists_fix_link($link, $action);
}
$items[] = array(
'data' => $link,
'class' => array('flag-lists-link', $action.'-action', 'fid-'.$flag->fid),
);
}
}
// dsm($items, 'items '.$entity->title);
#create new list
$link = l(
'<i class="icon-plus"></i>&nbsp;<span>' . t('New @name', array('@name' => t(variable_get('flag_lists_name', 'list')))) . '</span>',
'flag-lists/add/' . $entity->type,
array(
'attributes' => array(
'class' => array('flag-lists-create'),
'title' => t('create a new @name and use it.', array('@name'=>t(variable_get('flag_lists_name', 'list')))),
'nid' => $entity->nid,
'token' => flag_get_token($entity->nid),
),
'html' => TRUE,
)
);
$create = array(
'data' => $link,
'class' => array('flag-lists-create'),
);
}
if(isset($items)){
$ops = array(
'#node' => $entity,
'#items' => $items,
);
}
if(isset($create)){
$ops['#create'] = $create;
}
if(isset($ops)){
// dsm($ops, 'ops');
drupal_add_js(drupal_get_path('module', 'materio_flag').'/js/materio_flag.min.js');
$ops['#theme'] = "materio_flag_mylists_entity_links";
return $ops;
}
return;
}
function _materio_flag_get_listpagetitle($flag){
$cont = '<i class="icon-materio-folder"></i>';
$cont .= '<span class="'.$flag->name.'">'.check_plain($flag->title).'</span>';
if(flag_lists_is_owner('edit', $flag->fid)){
$cont .= l('<i class="icon-wrench"></i>',
'flags/lists/edit/'.$flag->fid,
array(
'html'=>true,
'attributes'=>array('class'=>array('edit-list', $flag->name)),
)
);
}
return $cont;
}
/**
* Implements hook_theme().
*/
function materio_flag_theme($existing, $type, $theme, $path) {
return array(
'materio_flag_mybookmarks_block' => array(
'arguments' => array(),
'template' => 'materio-flag-mybookmarks-block',
'path' => drupal_get_path('module', 'materio_flag').'/templates',
),
'materio_flag_mylists_block' => array(
'arguments' => array(),
'template' => 'materio-flag-mylists-block',
'path' => drupal_get_path('module', 'materio_flag').'/templates',
),
'materio_flag_mylists_nav_block' => array(
'arguments' => array(),
'template' => 'materio-flag-mylists-nav-block',
'path' => drupal_get_path('module', 'materio_flag').'/templates',
),
'materio_flag_mylists_entity_links' => array(
'variables' => array('node' => NULL, 'create' => NULL, 'items' => array()),
),
'materio_flag_mylists_list' => array(
'template' => 'materio-flag-mylists-list',
'path' => drupal_get_path('module', 'materio_flag').'/templates',
'variables' => array(
'count' => 0,
'items' => array(),
'view_mode' => 'teaser',
'pager' => NULL,
'fid' => null,
'name' => null,
'title' => null,
),
),
);
}
function template_preprocess_materio_flag_mybookmarks_block(&$vars){
// dsm($vars, 'vars');
}
function template_preprocess_materio_flag_mylists_block(&$vars){
// dsm($vars, 'vars');
}
function template_preprocess_materio_flag_mylists_nav_block(&$vars){
// dsm($vars, 'vars');
}
/**
* theme_materio_flag_mylists_entity_links()
*
* see theme_flag_lists_list()
*/
function theme_materio_flag_mylists_entity_links($vars){
// $node = $vars['node'];
$items = $vars['items'];
// dsm($vars, 'vars HO');
if(isset($vars['create']))
$items[] = $vars['create'];
return theme('item_list', array('items' => $items, 'type' => 'ul', 'attributes' => array('class' => 'flag-lists-entity-links')));
}
function template_preprocess_materio_flag_mylists_list(&$vars) {
$vars['list_count'] = format_plural(
$vars['count'],
'@name @title contains 1 item.', // in @sec seconds
'@name @title contains @count items.', // in @sec seconds
array(
'@name' => t($vars['name']),
'@title' => $vars['title'],
)
);
// dsm($vars, '$vars');
}

View File

@ -0,0 +1,497 @@
<?php
/**
* materio_flag_refresh_blocks($flag)
*
*/
function materio_flag_refresh_block($flag){
switch ($flag) {
case 'bookmarks':
$block_name = 'materio_flag_mybookmarks';
break;
case 'lists':
$block_name = 'materio_flag_mylists';
$block_nav_name = 'materio_flag_mylists_nav';
break;
}
if(!isset($block_name))
return;
$rep = array("flag"=>$flag);
$block = block_load('materio_flag', $block_name);
$block_content = _block_render_blocks(array($block));
$build = _block_get_renderable_array($block_content);
$block_rendered = drupal_render($build);
$rep['block'] = $block_rendered;
if(isset($block_nav_name)){
$block = block_load('materio_flag', $block_nav_name);
$block_content = _block_render_blocks(array($block));
$build = _block_get_renderable_array($block_content);
$block_rendered = drupal_render($build);
$rep['block_nav'] = $block_rendered;
}
drupal_json_output($rep);
}
/**
* materio_flag_createlist($type)
*
*/
function materio_flag_createlist_form($type){
$debug = false;
$path = 'flag-lists/add/' . $type;
// check if request is ajax, if not rediret
if (!$debug && (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')) {
drupal_goto('flag-lists/add/' . $type);
exit ;
}
// menu_set_active_item($path);
// $return = menu_execute_active_handler($path, FALSE);
// if (is_int($return)) {
// switch ($return) {
// case MENU_NOT_FOUND :
// drupal_add_http_header('Status', '404 Not Found');
// break;
// case MENU_ACCESS_DENIED :
// drupal_add_http_header('Status', '403 Forbidden');
// break;
// case MENU_SITE_OFFLINE :
// drupal_add_http_header('Status', '503 Service unavailable');
// break;
// }
// } elseif (isset($return)) {
// $form_state['build_info']['args'] = array(NULL, 'breve');
// $f = drupal_get_form('flag_lists_form', $form_state);
// dsm($f);
$form = array(
'#type' => 'form',
'#id' => 'materio-flag-create-list-form',
);
$form['type'] = array(
'#type' => 'hidden',
'#value' => $type,
'#name' => 'type',
);
$form['listname'] = array(
'#type' => 'textfield',
'#title' => t('Create new @name', array('@name'=>variable_get('flag_lists_name', 'list'))),
'#default_value' => '',
// '#size' => 100,
'#maxlength' => 255,
'#name' => 'flag-lists-name',
'#description' => t('A short, descriptive title for this Folder list. Limit to 255 characters.'),
);
$form['actions'] = array(
'#prefix' => '<div class="actions">',
'#suffix' => '</div>',
);
$form['actions']['create'] = array(
'#type' => 'submit',
'#value' => t('create'),
'#name' => 'create',
);
$form['actions']['cancel'] = array(
'#type' => 'button',
'#value' => t('cancel'),
'#name' => 'cancel',
);
// dsm($form, 'form');
$return = drupal_render($form);
$rep = array(
'rendered_form'=>$return,
);
if ($debug) {
dsm($rep, 'rep');
return "debug display";
}else{
drupal_json_output($rep);
}
}
/**
* materio_flag_editlist_form()
*/
function materio_flag_editlist_form($type, $fid){
$debug = false;
$path = 'flags/lists/edit/' . $fid;
// check if request is ajax, if not rediret
if (!$debug && (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')) {
drupal_goto($path);
exit ;
}
// If name is numeric, then we have the fid, so get the name.
if (is_numeric($fid)) {
$name = db_select('flag_lists_flags', 'f')
->fields('f', array('name'))
->condition('fid', $fid)
->execute()
->fetchField();
}
if(flag_lists_is_owner('edit', $fid)){
$flag = flag_lists_get_flag($name);
$form = array(
'#type' => 'form',
'#id' => 'materio-flag-edit-list-form',
);
$form['type'] = array(
'#type' => 'hidden',
'#value' => $type,
'#name' => 'type',
);
$form['fid'] = array(
'#type' => 'hidden',
'#value' => $fid,
'#name' => 'fid',
);
$form['name'] = array(
'#type' => 'hidden',
'#value' => $name,
'#name' => 'name',
);
$form['listtitle'] = array(
'#type' => 'textfield',
'#title' => t('Edit this '.variable_get('flag_lists_name', 'list')),
'#value' => $flag->title,
// '#size' => 100,
'#maxlength' => 255,
'#name' => 'flag-lists-title',
'#description' => t('A short, descriptive title for this Folder list. Limit to 255 characters.'),
);
$form['actions'] = array(
'#prefix' => '<div class="actions">',
'#suffix' => '</div>',
);
$form['actions']['save'] = array(
'#type' => 'submit',
'#value' => t('save'),
'#name' => 'save',
);
$form['actions']['delete'] = array(
'#type' => 'submit',
'#value' => t('delete'),
'#name' => 'delete',
);
$form['actions']['cancel'] = array(
'#type' => 'button',
'#value' => t('cancel'),
'#name' => 'cancel',
);
// dsm($form, 'form');
$return = drupal_render($form);
$rep = array(
'rendered_form'=>$return,
);
}else{
$rep = array(
'status' => 'error',
'message' => t('you do not have rights to edit this '.variable_get('flag_lists_name', 'list')),
);
}
if ($debug) {
dsm($rep, 'rep');
return "debug display";
}else{
drupal_json_output($rep);
}
}
function materio_flag_edit_list($fid, $name, $title){
$path = 'flags/lists/edit/' . $fid;
// check if request is ajax, if not rediret
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
drupal_goto($path);
exit ;
}
if(!flag_lists_is_owner('edit', $fid)){
$rep = array(
'error' => true,
'message' => t('You have not enough rights to edit this @name.', array('@name' => variable_get('flag_lists_name', t('list'))))
);
}else if (flag_lists_title_exists($title, 'materiau') || flag_lists_title_exists($title, 'breve')){
$rep = array(
'error' => true,
'message' => t('You already have a @name with this name.', array('@name' => variable_get('flag_lists_name', t('list'))))
);
}else{
$flag = flag_lists_get_flag($name);
$flag->title = $title;
flag_lists_set_messages($flag);
flag_lists_save($flag);
_flag_lists_clear_cache();
$rep = array(
'status' => 'saved',
'listname' => $name,
'listtitle' => $title,
);
}
drupal_json_output($rep);
}
function materio_flag_delete_list($fid){
$path = 'flags/lists/delete/' . $fid;
// check if request is ajax, if not rediret
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
drupal_goto($path);
exit ;
}
if(!flag_lists_is_owner('delete', $fid)){
$rep = array(
'error' => true,
'message' => t('You have not enough rights to delete this @name.', array('@name' => variable_get('flag_lists_name', t('list'))))
);
}else{
// If name is numeric, then we have the fid, so get the name.
if (is_numeric($fid)) {
$name = db_select('flag_lists_flags', 'f')
->fields('f', array('name'))
->condition('fid', $fid)
->execute()
->fetchField();
}
$flag = flag_lists_get_flag($name);
flag_lists_fl_delete($flag);
$rep = array(
'status' => 'saved',
);
}
drupal_json_output($rep);
}
function materio_flag_nodelinks(){
$nids = explode(';', $_REQUEST['nids']);
if(count($nids)){
foreach ($nids as $nid) {
$node = node_load($nid);
$lks = render(materio_flag_get_entity_links($node, 'node'));
$links[$nid] = $lks;
}
$rep = array(
"status" => 1,
"nids" => $nids,
'links' => $links,
);
}else{
$rep['status'] = 0;
}
drupal_json_output($rep);
}
function materio_flag_user_bookmarks(){
global $user;
drupal_set_title(t('My bookmarks'), PASS_THROUGH);
$flaged = flag_get_user_flags('node');
// dsm($flaged, 'flaged');
$flag = flag_get_flag('bookmarks');
$flaged_content = $flaged['bookmarks'];
// dsm($flaged_content, 'flaged_content');
$viewmode = isset($user->data['materiosearchapi_viewmode']) ? $user->data['materiosearchapi_viewmode'] : variable_get('defaultviewmode', 'full');
$limit = variable_get($viewmode.'_limite', '10');
$offset = pager_find_page() * $limit;
$count = count($flaged_content);
$max = $offset+$limit > $count ? $count : $offset+$limit;
$i = 0;
foreach ($flaged_content as $id => $item) {
if($i >= $offset){
if($i < $max){
if($item->entity_type == 'node'){
$items[] = node_load($id);
}
}else{
break;
}
}
}
$ret['#items'] = $items;
$ret['#theme'] = 'materio_flag_mylists_list';
$ret['#view_mode'] = $viewmode;
$ret['#fid'] = $flag->fid;
$ret['#count'] = $count;
$ret['#name'] = variable_get('flag_lists_name', 'list');
$ret['#title'] = $flag->title;
pager_default_initialize($count, $limit);
$ret['#pager'] = theme('pager');
drupal_add_js(drupal_get_path('module', 'materio_flag').'/js/materio_flag-ck.js');
return $ret;
}
function materio_flag_user_lists($fid){
global $user;
$flag = flag_lists_get_flag($fid);
// dsm($flag, 'flag');
drupal_set_title(_materio_flag_get_listpagetitle($flag), PASS_THROUGH);
$flaged_content = flag_lists_get_flagged_content($fid, $user->uid);
// dsm($flaged_content, 'flaged_content');
$viewmode = isset($user->data['materiosearchapi_viewmode']) ? $user->data['materiosearchapi_viewmode'] : variable_get('defaultviewmode', 'full');
$limit = variable_get($viewmode.'_limite', '10');
$offset = pager_find_page() * $limit;
$count = count($flaged_content);
$max = $offset+$limit > $count ? $count : $offset+$limit;
for ($i=$offset; $i < $max; $i++) {
if($flaged_content[$i]->entity_type == 'node'){
$items[] = node_load($flaged_content[$i]->entity_id);
}
}
$ret['#items'] = $items;
$ret['#theme'] = 'materio_flag_mylists_list';
$ret['#view_mode'] = $viewmode;
$ret['#fid'] = $fid;
$ret['#count'] = $count;
$ret['#name'] = variable_get('flag_lists_name', 'list');
$ret['#title'] = $flag->title;
pager_default_initialize($count, $limit);
$ret['#pager'] = theme('pager');
return $ret;
}
function materio_flag_ajax_list($fid, $page = 0){
$debug = false;
$_GET['page'] = $page;
if($fid == 1){
$list_path = $path = 'bookmarks';
}else{
$list_path = 'lists';
$path = $list_path.'/'.$fid;
}
// check if request is ajax, if not rediret to search_api_page page with right keys
if (!$debug && (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')) {
drupal_goto($path, array('query'=>array('page'=>$page)), 301);
exit;
}
if(isset($_GET['current_path'])){
// dsm($_GET['current_path'], '$_GET[current_path]');
// url() generates the prefix using hook_url_outbound_alter(). Instead of
// running the hook_url_outbound_alter() again here, extract the prefix
// from url().
url('', array('prefix' => &$prefix));
$cur_path = str_replace($base_url.base_path().$prefix, '', $_GET['current_path']);
// dsm($cur_path, 'cur_path');
$cur_is_list_path = strpos($cur_path, $list_path);
// dsm($matches, '$matches');
if($cur_is_list_path === false){
$rep = array(
"redirect" => $base_url.base_path().$prefix.$path,
);
drupal_json_output($rep);
exit;
}
}
// get results
menu_set_active_item($path);
$return = menu_execute_active_handler($path, FALSE);
dsm($return, '$return');
if (is_int($return)) {
switch ($return) {
case MENU_NOT_FOUND :
drupal_add_http_header('Status', '404 Not Found');
break;
case MENU_ACCESS_DENIED :
drupal_add_http_header('Status', '403 Forbidden');
break;
case MENU_SITE_OFFLINE :
drupal_add_http_header('Status', '503 Service unavailable');
break;
}
} elseif (isset($return)) {
if (is_array($return)) {
$rendered = drupal_render($return);
}
$rep = array(
'rendered' => $rendered,
'path' => $path,
'title' => drupal_get_title(),
);
if ($debug) {
dsm($rep, 'rep');
return "debug display";
}else{
drupal_json_output($rep);
}
}
}

View File

@ -0,0 +1,23 @@
name = Materio Page Title
description = "Provide a block with the current page title, and the ajax api to refresh it"
; Core version (required)
core = 7.x
; Package name (see http://drupal.org/node/542202 for a list of names)
package = Materio
; PHP version requirement (optional)
; php = 5.2
; Loadable code files
files[] = materio_page_title.module
; Module dependencies
; dependencies[] = materio_search_api
; Configuration page
; configure = admin/config/materio_search_api_ajax
; For further information about configuration options, see
; - http://drupal.org/node/542202

View File

@ -0,0 +1,148 @@
<?php
/**
* Implements hook_permission().
*/
function materio_page_title_permission() {
$perms = array();
$entity_infos = entity_get_info();
foreach ($entity_infos['node']['bundles'] as $bundle => $value) {
$perms['show '.$bundle.' title'] = array(
'title' => t('Show !bundle node title.', array('!bundle'=>$value['label'])),
);
}
return $perms;
}
/**
* Implements hook_field_access().
*/
function materio_page_title_field_access($op, $field, $entity_type, $entity, $account) {
if($field['field_name'] == 'title_field' && $entity_type == 'node' && isset($entity->type)){
return user_access('show '.$entity->type.' title');
}
return TRUE;
}
function materio_page_title_preprocess_html(&$vars){
// dsm($vars, '$vars');
// if (arg(0) == 'node' && $node = node_load(arg(1))) {
// if(!user_access('show '.$node->type.' title')){
// if($node->type == "materiau"){
// $title = field_get_items('node', $node, 'field_nature_titre');
// $vars['head_title_array']['title'] = $title[0]['safe_value'];
// }else{
// $vars['head_title_array']['title'] = 'restricted access';
// }
// $vars['head_title'] = implode(' | ', $vars['head_title_array']);
// // dsm($vars, 'vars');
// }
// }
$vars['head_title_array']['title'] = materio_page_title_get_title();
$vars['head_title'] = implode(' | ', $vars['head_title_array']);
$vars['head_array']['title'] = $vars['head_title'];
}
/**
* Implements hook_block_info().
*/
function materio_page_title_block_info() {
// This example comes from node.module.
/*
*$blocks['syndicate'] = array(
* 'info' => t('Syndicate'),
* 'cache' => DRUPAL_NO_CACHE
*);
*/
$blocks['materio_page_title'] = array(
'info' => t('Materio page title'),
'cache' => DRUPAL_NO_CACHE
);
return $blocks;
}
/**
* Implements hook_block_view().
*/
function materio_page_title_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'materio_page_title':
$block['subject'] = t('Page title');
$block['content'] = theme('materio_page_title', array('title' => materio_page_title_get_title()));
drupal_add_js(drupal_get_path('module', 'materio_page_title').'/js/materio_page_title.min.js');
break;
}
return $block;
}
/**
* Implements hook_theme().
*/
function materio_page_title_theme($existing, $type, $theme, $path) {
return array(
'materio_page_title' => array(
'variables' => array('title' => NULL,),
),
);
}
function theme_materio_page_title($vars){
if($vars['title'])
return '<h1 id="materio-page-title" class="page-title">'.$vars['title'].'</h1>';
return;
}
/**
* Implements hook_menu().
*/
// function materio_page_title_menu() {
// $items = array();
// $base = array(
// 'type' => MENU_CALLBACK,
// 'file' => 'materio_page_title.pages.inc',
// );
// $items['materio_page_title/refresh/block'] = $base+array(
// 'title' => 'Materio page title refresh block',
// 'page callback' => 'materio_page_title_refresh_block',
// 'page arguments' => array(),
// 'access callback' => TRUE,
// );
// return $items;
// }
/**
* HELPERS
* */
function materio_page_title_get_title(){
if (arg(0) == 'node' && $node = node_load(arg(1))) {
if(!user_access('show '.$node->type.' title')){
if($node->type == "materiau"){
$title = field_get_items('node', $node, 'field_nature_titre');
return $title[0]['safe_value'];
}else{
return 'restricted access';
}
}
}
return drupal_get_title();
}

View File

@ -0,0 +1,14 @@
<?php
// function materio_page_title_refresh_block(){
// $block = block_load('materio_page_title', 'materio_page_title');
// $block_content = _block_render_blocks(array($block));
// $build = _block_get_renderable_array($block_content);
// $block_rendered = drupal_render($build);
// $rep['block'] = $block_rendered;
// drupal_json_output($rep);
// }

View File

@ -0,0 +1,80 @@
<?php
function materio_search_api_settings(){
$indexes = search_api_index_load_multiple(false);
// dsm($indexes, '$indexes');
foreach ($indexes as $machine_name => $index) {
if($index->status == 1)
$index_options[$index->machine_name] = $index->name;
}
$languages = locale_language_list();
// dsm($languages, 'languages');
foreach ($languages as $lcode => $name) {
$form['fulltextsearchindex_'.$lcode] = array(
'#type'=>'select',
'#options'=>$index_options,
'#default_value' => variable_get('fulltextsearchindex_'.$lcode, -1),
'#title' => t('Full text search api index for %lang contents.', array('%lang'=>$name)),
);
$form['taxonomysearchindex_'.$lcode] = array(
'#type'=>'select',
'#options'=>$index_options,
'#default_value' => variable_get('taxonomysearchindex_'.$lcode, -1),
'#title' => t('Taxonomy search api index for %lang contents.', array('%lang'=>$name)),
);
$form['brevessearchindex_'.$lcode] = array(
'#type'=>'select',
'#options'=>$index_options,
'#default_value' => variable_get('brevessearchindex_'.$lcode, -1),
'#title' => t('Breves search api index for %lang contents.', array('%lang'=>$name)),
);
$form['autocompletesearchindex_'.$lcode] = array(
'#type'=>'select',
'#options'=>$index_options,
'#default_value' => variable_get('autocompletesearchindex_'.$lcode, -1),
'#title' => t('Autocomplete search api index for %lang contents.', array('%lang'=>$name)),
);
}
// TODO: select the activated viewmodes for change view mode and selected view mode
$entity_infos = entity_get_info();
// dsm($entity_infos, 'entity_infos');
foreach ($entity_infos['node']['view modes'] as $viewmode => $value) {
$viewmode_options[$viewmode] = $value['label'];
}
$form['availableviewmodes'] = array(
'#type'=>'select',
'#options'=>$viewmode_options,
'#default_value' => variable_get('availableviewmodes', array()),
'#title' => t('Availble View modes'),
'#multiple' => true,
);
$form['defaultviewmode'] = array(
'#type'=>'select',
'#options'=>$viewmode_options,
'#default_value' => variable_get('defaultviewmode', 'full'),
'#title' => t('Defalut View mode'),
);
foreach (variable_get('availableviewmodes', array()) as $viewmode => $value) {
$form[$viewmode.'_limite'] = array(
'#type'=>'textfield',
'#size'=>5,
'#default_value' => variable_get($viewmode.'_limite', '10'),
'#title' => t('@vm limite', array('@vm'=>$viewmode)),
);
}
return system_settings_form($form);
}

View File

@ -0,0 +1,29 @@
name = Materio SearchApi
description = "Materio Search Api module"
; Core version (required)
core = 7.x
; Package name (see http://drupal.org/node/542202 for a list of names)
package = Materio
; PHP version requirement (optional)
; php = 5.2
; Loadable code files
;files[] = materio_search_api.theme.inc
;files[] = materio_search_api.forms.inc
files[] = materio_search_api.pages.inc
files[] = materio_search_api.admin.inc
files[] = materio_search_api.module
; Module dependencies
;dependencies[] = taxonomy
dependencies[] = search_api
dependencies[] = search_api_solr
; Configuration page
; configure = admin/config/materiobasemod
; For further information about configuration options, see
; - http://drupal.org/node/542202

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,479 @@
<?php
/**
* materiobase_search_autocomplete_dbselect()
*
* inspired by taxonomy_autocomplete()
*
* OBSOLETE : this fonction use a direct dbselect request to provide results forautocomplete
*
*/
function materio_search_api_autocomplete_dbselect($typed = ''){
// If the request has a '/' in the search text, then the menu system will have
// split it into multiple arguments, recover the intended $tags_typed.
$args = func_get_args();
$typed = implode('/', $args);
/*
TODO riche serach engine + \\ etc gmail like
*/
if ($typed != '') {
// Part of the criteria for the query come from the field's own settings.
$vids = array();
$vocabularies = taxonomy_vocabulary_get_names();
foreach ($vocabularies as $voc) {
$vids[] = $voc->vid;
}
$query = db_select('taxonomy_term_data', 't');
$query->addTag('translatable');
$query->addTag('term_access');
// Select rows that match by term name.
$tags_return = $query
->fields('t', array('tid', 'name'))
->condition('t.vid', $vids)
->condition('t.name', '%' . db_like($typed) . '%', 'LIKE')
->range(0, 10)
->execute()
->fetchAllKeyed();
$term_matches = array();
foreach ($tags_return as $tid => $name) {
$n = $name;
// Term names containing commas or quotes must be wrapped in quotes.
// if (strpos($name, ',') !== FALSE || strpos($name, '"') !== FALSE) {
// $n = '"' . str_replace('"', '""', $name) . '"';
// }
$term_matches[$n] = check_plain($name);
}
}
drupal_json_output($term_matches);
}
/**
* materio_search_api_autocomplete_searchapi($typed = '')
*
* GOOD one using searchapi (SOLR)
*/
function materio_search_api_autocomplete_searchapi($typed = ''){
// If the request has a '/' in the search text, then the menu system will have
// split it into multiple arguments, recover the intended $tags_typed.
$args = func_get_args();
$typed = implode('/', $args);
// dsm($typed, 'typed');
if ($typed != '') {
// search for patterns like key -another key +lastkey
// and provide auto completion for the last key
preg_match_all('/\s?[\+|-]?[^\s]+/', $typed, $adv_search_q);
// dsm($adv_search_q, "adv_search_q");
preg_match('/^(\+|-)?(.*)$/', trim(array_pop($adv_search_q[0])), $last);
// dsm($last, "last");
$tosearch = isset($last[2]) ? $last[2] : $typed;
// build the query
global $language;
$index_machine_name = variable_get('autocompletesearchindex_'.$language->language, -1);
$query = search_api_query($index_machine_name);
// $query_filter = $query->createFilter();
// $query_filter->condition('name', $tosearch);
// $query_filter->condition('type', 'article');
// $query->filter($query_filter);
$query->keys($tosearch);
$tags_return = $query->execute();
// dsm($tags_return, '$tags_return');
if($tags_return['result count']){
$term_matches = array();
$index = search_api_index_load($index_machine_name);
$delta = 0;
foreach ($index->loadItems(array_keys($tags_return['results'])) as $item) {
//dsm($item, '$item');
//$term_matches[$item->tid] = check_plain($item->name);
// $term_matches[check_plain($item->name)] = check_plain($item->name);
// TODO: leave tags with nodes
$term_matches[trim(implode(' ', $adv_search_q[0]).' "'.$last[1].$item->name).'"'] = check_plain($item->name);
$delta++;
if($delta > 15)
break;
}
drupal_json_output($term_matches);
}else{
drupal_json_output(array());
}
}else{
return;
}
// dsm($term_matches, 'term_matches');
// return 'debug mode of materio_search_api_autocomplete_searchapi';
}
/**
* materio_search_api_results_search()
*
*
*/
function materio_search_api_results_search(){
//dsm("materio_search_api_results_search");
// retreive typed words separated by slashes as a sentence
$keys = func_get_args();
// dsm($args, 'args');
$typed = implode('/', $keys);
// remove query page params
preg_match_all('/\?page=([0-9]+)/', $typed, $pages);
//dsm($pages, '$pages');
if($pages[0]){
$typed = str_replace($pages[0][0], '', $typed);
}
// dsm($typed, 'typed');
if ($typed) {
global $language;
global $user;
# retrieve viewmode and then use it to define the query range
$viewmode = isset($user->data['materiosearchapi_viewmode'])
? $user->data['materiosearchapi_viewmode']
: variable_get('defaultviewmode', 'full');
$limit = variable_get($viewmode.'_limite', '10');
$offset = pager_find_page() * $limit; //$page*$limit;//
# Normal search
if(user_access('use materio search api')){
// dsm('normal search');
$results = msa_solrquery_materiauxbreves($typed, $language, $user, $offset, $limit);
}
# only breves search (+ related materials)
else if(user_access('use materio search api for breves')){
// dsm('limited search');
$results = msa_solrquery_breves($typed, $language, $user, $offset, $limit);
}
// for all case
$ret['results']['#results'] = $results;
$ret['results']['#items'] = $results['items'];
$ret['results']['#index'] = $results['index'];
$ret['results']['#theme'] = 'materio_search_api_results';
$ret['results']['#keys'] = $typed;
$ret['results']['#view_mode'] = $viewmode;
// page title
$page_title = $typed;
drupal_set_title('<i class="icon-materio-search"></i>'.check_plain($page_title), PASS_THROUGH);
// render results
if(isset($results)){
// Load pager.
// if ($results['result count'] > $page->options['per_page']) {
pager_default_initialize($results['result count'], $limit);
$ret['results']['#pager'] = theme('pager');
// }
if (!empty($results['ignored'])) {
drupal_set_message(
t('The following search keys are too short or too common and were therefore ignored: "@list".',
array( '@list' => implode(t('", "'), $results['ignored']) ) ),
'warning'
);
}
if (!empty($results['warnings'])) {
foreach ($results['warnings'] as $warning) {
drupal_set_message($warning, 'warning');
}
}
}
}
// dsm($ret, 'ret');
return $ret;
}
function msa_solrquery_materiauxbreves($typed, $language, $user, $offset, $limit){
// dsm($offset, 'offset');
// dsm($limit, 'limit');
// -- communs --//
# define default bundle option (materiaux, breves)
$default_bundles = array();
if(isset($taxo_index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles'])){
$indexed_bundles = $taxo_index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles'];
foreach ($indexed_bundles as $bundle) { $default_bundles[] = $bundle; }
}
# choose solr query bundle option
$bundles_filter = isset($user->data['materiosearchapi_bundlesfilter'])
? $user->data['materiosearchapi_bundlesfilter']
: $default_bundles;
# choose solr query options
$query_options = array('conjunction'=>'OR', 'parse mode'=>'direct');
// -- -- taxo search -- -- //
# define search api solr index
$taxo_index_machine_name = variable_get('taxonomysearchindex_'.$language->language, -1);
$taxo_index = search_api_index_load($taxo_index_machine_name);
#create the solr query for taxonomy search
$taxo_query = search_api_query($taxo_index_machine_name, $query_options)
->keys($typed);
# apply bundle options to solr query if usefull
if(count($bundles_filter)){
$filter = $taxo_query->createFilter('OR');
foreach ($bundles_filter as $type)
$filter->condition('type', $type, '=');
$taxo_query->filter($filter);
}
// $query->setOption('search_api_bypass_access', true);
# add user access solr query option
$taxo_query->setOption('search_api_access_account', $user);
#execute first time to get the all items, to be able to filter the full text research
$taxo_total_results = $taxo_query->execute();
// dsm($taxo_total_results, "taxo total results");
#add range to retriev the real current results
$taxo_query->range($offset, $limit);
# execute solr query and record results
$taxo_results = $taxo_query->execute();
// dsm($taxo_results, "taxo results");
$taxo_items = $taxo_index->loadItems(array_keys($taxo_results['results']));
// dsm($taxo_items, 'taxo items');
$taxo_results['items'] = $taxo_items;
$taxo_results['index'] = $taxo_index;//search_api_index_load($index_machine_name);
// -- -- full text search -- -- //
#define search api solr index
$fulltxt_index_machine_name = variable_get('fulltextsearchindex_'.$language->language, -1);
$fulltxt_index = search_api_index_load($fulltxt_index_machine_name);
#then calculate the good offset and limit for the complementary search
$fulltxt_offset = $offset - $taxo_results['result count'];
#create the solr query for taxonomy search
$fulltxt_query = search_api_query($fulltxt_index_machine_name, $query_options)
->keys($typed)
->range(($fulltxt_offset > 0 ? $fulltxt_offset : 0), $limit); // change offset to match with the first query (taxonomy)
# apply bundle options to solr query if usefull
if(count($bundles_filter)){
$filter = $fulltxt_query->createFilter('OR');
foreach ($bundles_filter as $type)
$filter->condition('type', $type, '=');
$fulltxt_query->filter($filter);
}
# filter to remove precedent search query
# !!!!!! THIS WILL NOT WORK, IT DOESN'T KNOW THE ITEMS FROM PAGES BEFORE THE CURRENT ONE ...
$nid_filter = $fulltxt_query->createFilter('AND');
foreach ($taxo_total_results['results'] as $nid => $item)
$nid_filter->condition('nid', $nid, '<>');
$fulltxt_query->filter($nid_filter);
# add user access solr query option
$fulltxt_query->setOption('search_api_access_account', $user);
# execute solr query and record results
$fulltxt_results = $fulltxt_query->execute();
// dsm($fulltxt_results, "fulltxt_results");
# add the full text result count to the taxo result to have the total of items
$taxo_results['result count'] += $fulltxt_results['result count'];
# if we are at the end of the first search results list
if($fulltxt_offset >= 0){
$fulltxt_items = $fulltxt_index->loadItems(array_keys($fulltxt_results['results']));
// dsm($fulltxt_items, 'full txt items');
$taxo_results['items'] += $fulltxt_items;
}
# TODO: cache the results with cache graceful : http://drupal.org/project/cache_graceful
return $taxo_results;
}
function msa_solrquery_breves($typed, $language, $user, $offset, $limit){
$index_machine_name = variable_get('brevessearchindex_'.$language->language, -1);
// dsm($index_machine_name, '$index_machine_name');
$index = search_api_index_load($index_machine_name);
# choose solr query options
$query_options = array('conjunction'=>'OR', 'parse mode'=>'direct');
#create the solr query
$query = search_api_query($index_machine_name, $query_options)
->keys($typed)
->range($offset, $limit);
// $query->setOption('search_api_bypass_access', true);
# add user access solr query option
$query->setOption('search_api_access_account', $user);
# execute solr query and record results
$results = $query->execute();
// dsm($results, 'results');
$results['index'] = $index;//search_api_index_load($index_machine_name);
#could
$could_index_machine_name = variable_get('fulltextsearchindex_'.$language->language, -1);
$could_index = search_api_index_load($could_index_machine_name);
# in case of free user search, run a real search to indicate how much items you could find
$could_query = search_api_query($could_index_machine_name, array('conjunction'=>'OR', 'parse mode'=>'direct'))
->keys($typed);
$could_results = $could_query->execute();
// dsm($could_results, 'could_results');
$results['could results'] = $could_results;
# add items : breve + materials wich are in the could result
$items = array();
$breves = $index->loadItems(array_keys($results['results']));
foreach ($breves as $nid => $breve) {
if(!node_access('view', $breve))
continue;
$items[] = $breve;
$materiaux = field_get_items('node',$breve,'field_materiau_ref');
// dsm($materiaux, 'materiaux');
if($materiaux){
foreach ($materiaux as $value) {
if(!isset($could_results['results'][$value['target_id']]))
continue;
$materiau = node_load($value['target_id']);
if(node_access('view', $materiau))
$items[] = $materiau;
}
}
}
$results['items'] = $items;
$results['breves count'] = $results['result count'];
$results['result count'] = count($items);
// dsm($results, "results");
# TODO: cache the results with cache graceful : http://drupal.org/project/cache_graceful
return $results;
}
/**
* materio_search_api_actuality()
*
*/
function materio_search_api_actuality(){
global $user;
if(isset($user->roles[1])){
$date_limit = strtotime('-6 month');
// dsm(date('d m y', $date_limit));
}
$viewmode = isset($user->data['materiosearchapi_viewmode']) ? $user->data['materiosearchapi_viewmode'] : variable_get('defaultviewmode', 'full');
$limit = 10;//variable_get($viewmode.'_limite', '10');
$offset = pager_find_page() * $limit;
// dsm($offset);
$query = new EntityFieldQuery;
$query
->entityCondition('entity_type', 'node')
->propertyCondition('status', 1)
->entityCondition('bundle', array('breve'))
->propertyOrderBy('created', 'DESC')
->range($offset,$limit);
if(isset($user->roles[1])){
$query->propertyCondition('created', $date_limit, '>');
}
$result = $query->execute();
// dsm($result, '$result');
$count_query = new EntityFieldQuery;
$count_query
->entityCondition('entity_type', 'node')
->propertyCondition('status', 1)
->entityCondition('bundle', array('breve'));
// dsm($count, 'count');
if(isset($user->roles[1])){
$count_query->propertyCondition('created', $date_limit, '>');
}
$count = $count_query->count()->execute();
pager_default_initialize($count, $limit);
$items = array();
if(isset($result['node'])){
foreach ($result['node'] as $nid => $n) {
$breve = node_load($nid);
if(!node_access('view', $breve))
continue;
$items[] = $breve;
$materiaux = field_get_items('node',$breve,'field_materiau_ref');
// dsm($materiaux, 'materiaux');
if($materiaux){
foreach ($materiaux as $value) {
$materiau = node_load($value['target_id']);
if(node_access('view', $materiau))
$items[] = $materiau;
}
}
}
}
// drupal_set_title(t('Actualities'));
drupal_set_title(t(''));
return theme('materio_search_api_actuality', array(
'items' => $items,
'view_mode' => $viewmode,
'count' => $count,
'pager' => theme('pager'),
));
}
function materio_search_api_viewmode_change($vm){
//dsm($vm, 'materio_search_api_viewmode_change');
$rep = _materio_search_api_change_viewmode($vm);
//return 'debug mode for materio_search_api_viewmode_change';
// drupal_json_output($rep);
drupal_goto();
}

View File

@ -0,0 +1,29 @@
name = Materio Search API Ajax
description = "The description of this module"
; Core version (required)
core = 7.x
; Package name (see http://drupal.org/node/542202 for a list of names)
package = Materio
; PHP version requirement (optional)
; php = 5.2
; Loadable code files
files[] = materio_search_api_ajax.module
; files[] = materio_search_api_ajax.admin.inc
; files[] = materio_search_api_ajax.class.inc
; Module dependencies
; dependencies[] = materio_search_api
; dependencies[] = theirmodule (1.2)
; dependencies[] = anothermodule (>=2.4)
; dependencies[] = views (3.x)
; Configuration page
; configure = admin/config/materio_search_api_ajax
; For further information about configuration options, see
; - http://drupal.org/node/542202

View File

@ -0,0 +1,68 @@
<?php
/**
* @file
* This is the file description for materio_search_api_ajax module.
*
* In this more verbose, multi-line description, you can specify what this
* file does exactly. Make sure to wrap your documentation in column 78 so
* that the file can be displayed nicely in default-sized consoles.
*/
/**
* Implements hook_init().
*/
function materio_search_api_ajax_init() {
if (module_exists('locale')) {
$languages = language_list('enabled');
}
drupal_add_js(array('materio_search_api_ajax' => array(
'module_path' => drupal_get_path('module', 'materio_search_api_ajax'),
// 'strings'=>array(
// 'sitetitle'=>,
// 'siteslogan'=>,
// ),
'languages' => isset($languages) ? $languages[1] : array(),
)), 'setting');
drupal_add_js(drupal_get_path('module', 'materio_search_api_ajax').'/js/materio_search_api_ajax.min.js');
}
/**
* Implements hook_menu().
*/
function materio_search_api_ajax_menu() {
$items = array();
$base = array(
'type' => MENU_CALLBACK,
'file' => 'materio_search_api_ajax.pages.inc',
);
$items['materio_search_api_ajax/search'] = $base+array(
'title' => 'Matrio base ajax',
'page callback' => 'materio_search_api_ajax_search',
'page arguments' => array(2),
'access callback' => TRUE,
'access arguments' => array('use materio search api'),
);
$items['materio_search_api_ajax/viewmode/change'] = $base+array(
'page callback' => 'materio_search_api_ajax_viewmode_change',
'page argument' => array(3),
'access arguments' => array('use materio search api viewmode selection'),
);
$items['materio_search_api_ajax/actuality'] = $base+array(
'page callback' => 'materio_search_api_ajax_actuality',
'access callback' => TRUE,
'page arguments' => array(2),
);
$items['materio_search_api_ajax/node'] = $base+array(
'page callback' => 'materio_search_api_ajax_node',
'access callback' => TRUE,
'page arguments' => array(2),
);
return $items;
}

View File

@ -0,0 +1,247 @@
<?php
function materio_search_api_ajax_search($page = 0){
$debug = false;
global $user, $base_url;
// TODO: set research path configurable
$search_path = "explore";
# execute search
$_GET['page'] = $page;
$keys = rawurldecode($_GET['keys']);
foreach(explode(' ', $keys) as $word){
$words[] = rawurlencode($word);
}
$keys_encoded = implode(' ', $words);
// dsm($words, 'words');
$path = $search_path . '/' . $keys;//. ($page ? '?page='.$page : '');
// check if request is ajax, if not rediret to search_api_page page with right keys
if (!$debug && (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')) {
drupal_goto($path, array(), 301);
exit ;
}
// TODO: if no permission, redirect to home
# content type filter s
// $types = $_GET['types'];
if(isset($_GET['types'])){
# if user have access to filters;
foreach($_GET['types'] as $type => $value)
if($value == 'true')
$active_types[] = $type;
// if no filter checked we checked them all by default
if(!isset($active_types))
foreach($_GET['types'] as $type => $value)
$active_types[] = $type;
}else{
# if user have no access to filters
$index = search_api_index_load(variable_get('mainsearchindex', -1));
$indexed_bundles = $index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles'];
foreach ($indexed_bundles as $bundle) {
$active_types[] = $bundle;
}
}
user_save($user, array("data"=>array('materiosearchapi_bundlesfilter' => $active_types)));
# if we are not already on the search page then don't respond with search results but redirect to search page
if(isset($_GET['current_path'])){
// url() generates the prefix using hook_url_outbound_alter(). Instead of
// running the hook_url_outbound_alter() again here, extract the prefix
// from url().
url('', array('prefix' => &$prefix));
$cur_path = str_replace($base_url.base_path().$prefix, '', $_GET['current_path']);
// dsm($cur_path, 'cur_path');
$cur_is_search_path = strpos($cur_path, $search_path);
// dsm($matches, '$matches');
if($cur_is_search_path === false){
$rep = array(
"redirect" => $base_url.base_path().$prefix.$path,
);
drupal_json_output($rep);
exit;
}
}
// define mode (between full text or only term selected on autocompletion)
// TODO implement the new search mode (only term)
if(isset($_GET['searchmode'])){
$searchmode = $_GET['searchmode'];
user_save($user, array("data"=>array('materiosearchapi_searchmode' => $searchmode)));
}
// dsm($path, 'path');
// execute the searcj path and retrive results
menu_set_active_item($path);
$return = menu_execute_active_handler($path, FALSE);
//dsm($return, '$return');
if (is_int($return)) {
switch ($return) {
case MENU_NOT_FOUND :
drupal_add_http_header('Status', '404 Not Found');
break;
case MENU_ACCESS_DENIED :
drupal_add_http_header('Status', '403 Forbidden');
break;
case MENU_SITE_OFFLINE :
drupal_add_http_header('Status', '503 Service unavailable');
break;
}
} elseif (isset($return)) {
if (is_array($return)) {
$count = $return['results']['#results']['result count'];
$return = drupal_render($return);
// $return = theme($return['#theme'], $return);
}
$rep = array(
'path'=>$search_path.'/'.$keys_encoded,
'keys'=>$keys,
'keys_encoded'=>$keys_encoded,
'search_path'=>$search_path,
'returned'=>$return,
'active_types'=>$active_types,
'title' => drupal_get_title(),
);
if(isset($count))
$rep['count'] = $count;
if ($debug) {
//dsm($rep, 'rep');
return "debug display";
}else{
drupal_json_output($rep);
}
}
}
function materio_search_api_ajax_viewmode_change($vm){
// dsm($vm);
// global $user;
// // dsm($user, 'user');
// $entity_infos = entity_get_info();
// // dsm($entity_infos, 'entity_infos');
// if (in_array($vm, variable_get('availableviewmodes', array()))) {
// user_save($user, array("data"=>array('materiosearchapi_viewmode' => $vm)));
// $rep = array('statut'=>'saved');
// }else{
// $rep = array('statut'=>'viewmode not allowed');
// }
$_GET['page'] = 0;
$rep = _materio_search_api_change_viewmode($vm);
drupal_json_output($rep);
}
function materio_search_api_ajax_actuality($page = 0){
$debug = false;
$_GET['page'] = $page;
$path = 'actuality';
// check if request is ajax, if not rediret to search_api_page page with right keys
if (!$debug && (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')) {
drupal_goto($path, array(), 301);
exit ;
}
// if(isset($_GET['current_path'])){
// // dsm($_GET['current_path'], '$_GET[current_path]');
// // url() generates the prefix using hook_url_outbound_alter(). Instead of
// // running the hook_url_outbound_alter() again here, extract the prefix
// // from url().
// url('', array('prefix' => &$prefix));
// $cur_path = str_replace($base_url.base_path().$prefix, '', $_GET['current_path']);
// // dsm($cur_path, 'cur_path');
// $cur_is_search_path = strpos($cur_path, $search_path);
// // dsm($matches, '$matches');
// if($cur_is_search_path === false){
// $rep = array(
// "redirect" => $base_url.base_path().$prefix.$path,
// );
// drupal_json_output($rep);
// exit;
// }
// }
// get results
menu_set_active_item($path);
$return = menu_execute_active_handler($path, FALSE);
//dsm($return, '$return');
if (is_int($return)) {
switch ($return) {
case MENU_NOT_FOUND :
drupal_add_http_header('Status', '404 Not Found');
break;
case MENU_ACCESS_DENIED :
drupal_add_http_header('Status', '403 Forbidden');
break;
case MENU_SITE_OFFLINE :
drupal_add_http_header('Status', '503 Service unavailable');
break;
}
} elseif (isset($return)) {
if (is_array($return)) {
$return = drupal_render($return);
}
$rep = array(
'path' => $path,
'returned'=>$return,
'title' => drupal_get_title(),
);
if ($debug) {
//dsm($rep, 'rep');
return "debug display";
}else{
drupal_json_output($rep);
}
}
}
function materio_search_api_ajax_node($nid){
global $user;
$viewmode = isset($_GET['viewmode']) ? $_GET['viewmode'] : (isset($user->data['materiosearchapi_viewmode']) ? $user->data['materiosearchapi_viewmode'] : variable_get('defaultviewmode', 'full'));
$rep = array(
"get" => $_GET,
"viewmode" => $viewmode
);
if($nodeview = node_view(node_load($nid),$viewmode)){
$rep = $rep+array(
'nid' => $nid,
'node' => drupal_render($nodeview),
);
drupal_json_output($rep);
}
}

View File

@ -0,0 +1,29 @@
name = Materio Taxonomy
description = "The description of this module"
; Core version (required)
core = 7.x
; Package name (see http://drupal.org/node/542202 for a list of names)
package = Materio
; PHP version requirement (optional)
; php = 5.2
; Loadable code files
files[] = materio_taxonomy.module
; files[] = materio_search_api_ajax.admin.inc
; files[] = materio_search_api_ajax.class.inc
; Module dependencies
dependencies[] = taxonomy
; dependencies[] = theirmodule (1.2)
; dependencies[] = anothermodule (>=2.4)
; dependencies[] = views (3.x)
; Configuration page
; configure = admin/config/materio_search_api_ajax
; For further information about configuration options, see
; - http://drupal.org/node/542202

View File

@ -0,0 +1,77 @@
<?php
/**
* Implements hook_permission().
*/
function materio_taxonomy_permission() {
$perms = array();
// foreach (taxonomy_get_vocabularies() as $voc) {
// dsm($voc, '$voc');
// // $perms['access taxonomy term page'] => array(
// // 'title' => t(''),
// // 'description' => t(''),
// // );
// }
$perms['access taxonomy terms page'] = array(
'title' => t('access taxonomy terms page'),
'description' => t(''),
);
return $perms;
}
function materio_taxonomy_menu_alter(&$items) {
$items['taxonomy/term/%taxonomy_term']['access arguments'] = array('access taxonomy terms page');
$items['taxonomy/term/%taxonomy_term/view']['access arguments'] = array('access taxonomy terms page');
$items['taxonomy/term/%taxonomy_term/feed']['access arguments'] = array('access taxonomy terms page');
}
/**
* Implementation of hook_query_term_access_alter().
*
* debug de i18n_select_query_term_access_alter()
* qui filtre les terms par language mm pour les vocabulaires en mode localized.
* utile pour la recherche avancée de materio_search_api materio_search_api_advanced_search_form()
*
*/
function materio_taxonomy_query_term_access_alter(QueryAlterableInterface $query) {
// dsm($query, 'materio taxo query');
$conditions =& $query->conditions();
# roll over condition first time to determine i18n_voc_mode
$i18n_voc_mode = 0;
foreach ($conditions as $condition) {
if (is_array($condition)) {
// dsm($condition, 'conditon '.$condition['field']);
if($condition['field'] == 't.vid'){
$vid = $condition['value'];
$i18n_voc_mode = i18n_taxonomy_vocabulary_mode($vid);
// dsm($i18n_voc_mode, 'i18n_voc_mode');
}
}
}
# roll over conditions a second time to re-alter/fixe language selection
# i18n vocabulary mode is 1 for localized terms
if($i18n_voc_mode == 1){
foreach ($conditions as $index => $condition) {
if (is_array($condition)) {
// dsm($condition, 'conditon '.$condition['field']);
if($condition['field'] == 't.language' && $i18n_voc_mode == 1){
$l = array('und');
$ll = i18n_language_list();
// dsm($ll, 'list language');
foreach ($ll as $langcode => $langname) {
$l[] = $langcode;
}
$conditions[$index]['value'] = $l;
}
}
}
}
}

View File

@ -0,0 +1,23 @@
name = Materio User
description = "Materio user generalist module"
; Core version (required)
core = 7.x
; Package name (see http://drupal.org/node/542202 for a list of names)
package = Materio
; PHP version requirement (optional)
; php = 5.2
; Loadable code files
files[] = materio_ctools_automodal.module
; Module dependencies
dependencies[] = user
; Configuration page
; configure = admin/config/materiobasemod
; For further information about configuration options, see
; - http://drupal.org/node/542202

View File

@ -0,0 +1,653 @@
<?php
/**
* Implements hook_init().
*/
function materio_user_init() {
drupal_add_js(drupal_get_path('module', 'materio_user').'/js/materio_user.min.js');
}
/**
* Implements hook_permission().
*/
function materio_user_permission() {
return array(
'view own user profile' => array(
'title' => t('view own user profile'),
'description' => t('view own user profile'),
),
'access to online payment' => array(
'title' => t('access to online payment'),
'description' => t('Access to online payment'),
),
);
}
function materio_user_menu(){
$items = array();
$base = array(
'type' => MENU_CALLBACK,
'file' => 'materio_user.pages.inc',
);
$items['materio_user/registerblock'] = $base+array(
'title' => 'Materio base user ajax',
'page callback' => 'materio_user_registerblock',
// 'page arguments' => array(),
'access callback' => TRUE,
);
$items['materio_user/loginandregisterblock'] = $base+array(
'title' => 'Materio base user ajax',
'page callback' => 'materio_user_loginandregisterblock',
// 'page arguments' => array(),
'access callback' => TRUE,
);
$items['materio_user/register/submit'] = $base+array(
'title' => 'Materio base user ajax',
'page callback' => 'materio_user_register_submit',
// 'page arguments' => array(),
'access callback' => TRUE,
);
$items['materio_user/login/submit'] = $base+array(
'title' => 'Materio base user ajax',
'page callback' => 'materio_user_login_submit',
// 'page arguments' => array(),
'access callback' => TRUE,
);
return $items;
}
/**
* Implements hook_menu_alter().
*/
function materio_user_menu_alter(&$items) {
$items['user/%user']['access callback'] = 'user_access';
$items['user/%user']['access arguments'] = array('view own user profile');
}
/**
* Implements hook_block_info().
*/
function materio_user_block_info() {
$blocks['user_createaccount'] = array(
'info' => t('Create an account block'),
'cache' => DRUPAL_NO_CACHE
);
$blocks['user_register'] = array(
'info' => t('Register block'),
'cache' => DRUPAL_NO_CACHE
);
$blocks['old_database_link'] = array(
'info' => t('Old data base link'),
'cache' => DRUPAL_NO_CACHE
);
$blocks['front_link'] = array(
'info' => t('Front page link'),
'cache' => DRUPAL_NO_CACHE
);
return $blocks;
}
/**
* Implements hook_block_view().
*/
function materio_user_block_view($delta = '') {
global $user, $language;
$block = array();
switch ($delta) {
case 'user_createaccount':
if(isset($user->roles[1])){
$block['subject'] = '';
if (drupal_is_front_page()) {
$block['content'] .= '<h3>'. t('Create your materiO\' account') . '</h3>';
$block['content'] .= l(t('Join us'), 'node/11187', array("attributes"=>array("class"=>array("join"))));
}else{
$block['content'] .= '<h3>'. t('Create your materiO\' account') . '</h3>';
$block['content'] .= drupal_render(drupal_get_form('user_register_form'));
}
}
break;
case 'user_register':
if(isset($user->roles[1])){
$block['subject'] = '';//drupal_is_front_page() ? t('Your projects will born from here') : t('Create your materiO\' account');
$block['content'] = '<h3>'. t('Login') . '</h3>';
$ulog_form = drupal_get_form('user_login');
$block['content'] .= drupal_render($ulog_form);
if (drupal_is_front_page()) {
$block['content'] .= '<h3>'. t('<span>or </span>create your materiO\' account') . '</h3>';
$block['content'] .= l(t('Join us'), 'node/11187', array("attributes"=>array("class"=>array("join"))));
}else{
$block['content'] .= '<h3>'. t('<span>or </span>create your materiO\' account') . '</h3>';
$block['content'] .= drupal_render(drupal_get_form('user_register_form'));
}
// $block['content'] .= l(t('Pricing'), 'node/11187', array('attributes' => array('class' => 'pricing'),));
}
break;
case 'old_database_link':
if( (isset($user->roles[6]) || isset($user->roles[8])) && $user->created < strtotime('01-12-2012') ){
// dsm($user, 'user');
$block['subject'] = '';
$path = 'http://base.materio.com';
if($language->language == 'fr')
$path .= '/index_fr.html';
$block['content'] = l(t('Old database'), $path);
}
break;
case 'front_link':
$block['subject'] = '';
$block['content'] = l('<i class="icon-home"></i><span class="text">'.t('home').'</span>', '<front>', array('html'=>true));
break;
}
return $block;
}
/**
* Implements hook_form_alter().
*/
function materio_user_form_alter(&$form, &$form_state, $form_id) {
// dsm($form_id);
if( $form_id == "user_register_form" && !user_access('administer users') ){
// dsm($form);
$form['account']['pass']['#type'] = 'password';
$form['account']['pass']['#title'] = t('Password');
$form['actions']['#type'] = "container";
$form['actions']['submit']['#value'] = t('Join');
// $form['termsofservices'] = array(
// '#type' => 'checkbox',
// '#title' => t('I accept') .' '. l(t('the materiO terms of services'), 'node/11183'),
// '#required' => true,
// );
// $form['#submit'][] = "materio_user_user_register_form_submit";
}
if($form_id == "user_login" ){
// dsm($form);
$form['actions']['#type'] = "container";
// $form['actions']['submit']['#value'] = t('Join');
// if( $_GET['q'] == 'node/11187' ){
// $form['#submit'][] = "materio_user_user_login_form_submit";
// }
}
# https://drupal.org/comment/6293810#comment-6293810
if( $form_id == "webform_client_form_11186" ){
// dsm($form, '$form');
materio_user_webform_client_11186_form_alter($form, $form_state, $form_id);
}
if( $form_id == "uc_cart_checkout_form" ){
materio_user_uc_cart_checkout_form_alter($form, $form_state, $form_id);
}
// if( $form_id == "user_profile_form" ){
// //dsm($form, '$form');
// $form['account']['pass']['#type'] = "new_password_confirm";
// }
}
// function materio_user_user_register_form_submit($form, &$form_state){
// dsm($form, 'form');
// dsm($form_state, 'form_state');
// dsm($_REQUEST, '$_REQUEST');
// dsm($_GET, '$_GET');
// unset($_REQUEST['destination'], $_REQUEST['edit']['destination']);
// $form_state['redirect'] = array(
// 'node/11187',
// array(
// 'fragment' => $_GET['q'] == 'node/11187' ? 'content-bottom' : '', // if we register from the membership page, then go directly to the form
// )
// );
// $frontlink = l('continue with basic', '<front>');
// // drupal_get_messages('status');
// drupal_set_message(t('Welcome, you just join materiO\'! now you can choose the membership that\'s right for you, or !link', array('!link'=>$frontlink)));
// }
// function materio_user_user_login_form_submit($form, &$form_state){
// unset($_REQUEST['destination'], $_REQUEST['edit']['destination']);
// $form_state['redirect'] = array(
// 'node/11187',
// array(
// 'fragment' => 'content-bottom', // if we login from the membership page, then go directly to the form
// )
// );
// }
/**
* subscription webform (nid : 11186)
*/
# prefill the webform form with user profil values
# add validate and submit functions
function materio_user_webform_client_11186_form_alter(&$form, &$form_state, $form_id){
// dsm($form_id, 'form_id');
// dsm($form, "form");
// dsm($form_state, "form_state");
$form['#validate'][] = "materio_user_webform_client_11186_validate";
$form['#submit'][] = "materio_user_webform_client_11186_submit";
# dont fill default values if form is been rebuilded (by address module)
if($form_state["rebuild"])
return;
global $user;
// dsm($user, 'user');
$member_profile = profile2_load_by_user($user, 'adherent');
// dsm($member_profile, "member_profile");
$columnright = &$form['submitted']['column_right'];
$columnright['me']['firstname']['#default_value'] = $member_profile->field_first_name['und'][0]['value'];
$columnright['me']['name']['#default_value'] = $member_profile->field_name['und'][0]['value'];
$columnright['company']['administrative_e_mail']['#default_value'] = $member_profile->field_administrative_email['und'][0]['value'];
$columnright['company']['s']['company']['#default_value'] = $member_profile->field_organization['und'][0]['value'];
$columnright['company']['s']['activity_sector']['#default_value'] = $member_profile->field_activity_sector['und'][0]['value'];
$columnright['company']['d']['vat_number_intra_ce']['#default_value'] = $member_profile->field_vat_number_intra_ce['und'][0]['value'];
$columnright['company']['d']['website']['#default_value'] = $member_profile->field_user_website['und'][0]['url'];
if( isset($member_profile->field_adresse['und'][0]) ){
$address = $member_profile->field_adresse['und'][0];
$formaddress = &$columnright['company']['location']['#address'];
$formaddress['country'] = $address['country'];
$formaddress['thoroughfare'] = $address['thoroughfare'];
$formaddress['premise'] = $address['premise'];
$formaddress['postal_code'] = $address['postal_code'];
$formaddress['locality'] = $address['locality'];
}
$columnright['company']['phone_number']['#default_value'] = $member_profile->field_private_phone['und'][0]["number"];
}
function materio_user_webform_client_11186_validate($form, &$form_state){
// dsm($form, 'form');
// dsm($form_state, 'form_state');
# test if collaborators are filled in case of membership option is 3
$values = $form_state['values']['submitted'];
if ($values['column_left']['membership_options'] == 3) {
foreach ($values['column_right']['collaborators'] as $collab_key => $coll) {
foreach ($coll as $field_key => $field_value) {
$form_field = $form['submitted']['column_right']['collaborators'][$collab_key][$field_key];
if($field_value == ''){
$collab_label = $form['submitted']['column_right']['collaborators'][$collab_key]['#title'];
$field_label = $form_field['#title'];
$human_field_name = $collab_label. " : " .$field_label;
form_error($form_field, t('You must provide a value for the !name field.', array('!name'=>$human_field_name)));
}
# validate the emails
# see https://api.drupal.org/api/drupal/modules!user!user.module/function/user_account_form_validate/7
if($form_field['#type'] == 'webform_email'){
// dsm($form_field, 'form_field');
$u = db_select('users')
->fields('users', array('uid'))
// ->condition('uid', $account->uid, '<>')
->condition('mail', db_like($field_value), 'LIKE')
->range(0, 1)
->execute()->fetchField();
if ((bool) $u ) {
form_error($form_field, t('The e-mail address %email is already taken.', array('%email' => $field_value)));
}
}
}
}
}
}
#retreive from the web form info, record them into user profil
function materio_user_webform_client_11186_submit(&$form, &$form_state){
// dsm($form, 'form');
// dsm($form_state, 'form_state');
$node = &$form['#node'];
// dsm($node, '$node');
$values = $form_state['values']['submitted_tree'];
// dsm($values, '$values');
$flat_values = array();
materio_user_flatenize_form_values($values, $flat_values);
// dsm($flat_values, 'flat_values');
# records values in member profile
materio_user_record_member_profile($flat_values);
# redirect membership form to checkout with good option selected
if(user_access('access to online payment')){
// forcer le vidage du panier
uc_cart_empty(uc_cart_get_id());
// fill the cart and redirect to checkout
// cf : http://www.ubercart.org/node/1427
$subscription_level = $flat_values['membership_options'];
$form_state['redirect'] = array(
'cart/add/e-p11849_q1_a1o'.$subscription_level.'-membershipform',
array(
'query' => array(
'destination' => 'cart/checkout',
),
// 'fragment' => 'baz',
),
);
// TODO effacer le message de soumissions du formulaire -> pas moyen de overwriter le message de webform depuis ici, dommage
// $node->webform['confirmation'] = '';
# create collaborators users account incase of membership option is 3
# NO wait for checkout for that
//materio_user_create_collaborators_users();
// enregistrer le type d'adonnement chez les user
}
}
function materio_user_record_member_profile($values) {
// dsm($values, 'values');
global $user;
// dsm($user, 'user');
$member_profile = profile2_load_by_user($user, 'adherent');
if (empty($member_profile)) {
$member_profile = profile2_create(array("type" => 'adherent', "uid" => $user->uid));
}
// dsm($member_profile, '$member_profile');
$correspondances = array(
"firstname"=>"field_first_name",
"name"=>"field_name",
"company"=>"field_organization",
"activity_sector"=>"field_activity_sector",
"website"=>"field_user_website",
"administrative_e_mail"=>"field_administrative_email",
"vat_number_intra_ce"=>"field_vat_number_intra_ce",
"location"=>"field_adresse",
"phone_number"=>"field_private_phone",
);
foreach ($correspondances as $form_field => $field_name) {
switch($form_field){
case "website":
$value = array("url" => $values[$form_field]);
break;
case "administrative_e_mail":
$value = array("email" => $values[$form_field]);
break;
case "location":
$value = unserialize($values[$form_field]);
// dsm($value, 'location value');
break;
case "phone_number":
$pn = $values[$form_field];
if(module_exists('cck_phone')){
preg_match('/^(\+[0-9]+)\s([0-9]+)$/', $pn, $matches);
// dsm($matches, "matches");
$ccs = cck_phone_countrycodes();
foreach ($ccs as $c => $vs) {
if($vs['code'] == $matches[1]){
$pn = "0".$matches[2];
$cc = $c;
break;
}
}
$value = array(
"number"=>$pn,
"country_codes"=>$cc,
"extension"=>"",
);
}else{
$value = array(
"number"=>$pn,
"country_codes"=>"",
"extension"=>"",
);
}
break;
default:
$value = array("value" => $values[$form_field]);
break;
}
$member_profile->{$field_name} = array(
"und"=>array( 0 => $value,)
);
}
// save the profile2 new contents
profile2_save($member_profile);
// Indicate success to the user.
// drupal_set_message(t('Your member profile has been created.'));
}
function materio_user_flatenize_form_values($ar_src, &$flat_ar){
foreach ($ar_src as $key => $value) {
if(is_array($value)){
materio_user_flatenize_form_values($value, $flat_ar);
}else{
$flat_ar[$key] = $value;
}
}
}
/**
* Implements hook_form_alter().
*/
function materio_user_uc_cart_checkout_form_alter(&$form, &$form_state, $form_id) {
// dsm($form_id, 'form_id');
// dsm($form, "form");
// dsm($form_state, "form_state");
// Load an order from the session, if available.
if (isset($_SESSION['cart_order'])) {
$order = uc_order_load($_SESSION['cart_order']);
if ($order) {
// dsm($order, 'order');
global $user;
// dsm($user, 'user');
$member_profile = profile2_load_by_user($user, 'adherent');
// dsm($member_profile, "member_profile");
$location = (object) $member_profile->field_adresse['und'][0];
# convert country code to UC country ID (pfff)
$countries = db_query("SELECT country_id, country_iso_code_2 FROM {uc_countries} WHERE version > :version", array(':version' => 0))->fetchAllKeyed();
foreach ($countries as $country_id => $country_code) {
if($location->country == $country_code){
$location->uc_country_id = $country_id;
break;
}
}
// dsm($location, "location");
// $phone_field = field_get_items('profile2', $member_profile, 'field_private_phone');
// $phone = $phone_field ? field_view_value('profile2', $member_profile, 'field_private_phone', $phone_field[0]) : "";
// dsm($phone, 'phone');
$phone_field = $member_profile->field_private_phone['und'][0];
if(module_exists('cck_phone')){
$cc = cck_phone_countrycodes($phone_field['country_codes']);
$phone = $cc['code'] .' '. $phone_field['number'];
}
$correspondances = array(
"billing_first_name" => $member_profile->field_first_name['und'][0]['value'],
"billing_last_name" => $member_profile->field_name['und'][0]['value'],
"billing_phone" => $phone,
"billing_company" => $member_profile->field_organization['und'][0]['value'],
"billing_street1" => $location->thoroughfare,
"billing_street2" => $location->premise,
"billing_city" => $location->locality,
// "billing_zone" => ,
"billing_postal_code" => $location->postal_code,
"billing_country" => $location->uc_country_id,
);
foreach ($correspondances as $order_field => $value) {
$order->{$order_field} = $value;
}
$form['panes']['billing']['address']['#default_value'] = $order;
}
}
}
/**
* Implements hook_uc_order();
*/
function materio_user_order($op, $order, $arg2) {
// dsm($op, "matyerio_user_uc_order | op");
// dsm($order, "order");
// dsm($arg2, "arg2");
switch ($op) {
case 'save':
// Do something to save payment info!
break;
}
}
# not used yet
function materio_user_create_collaborators_users(){
/*
if ($values['membership_options'] == 3) {
$i = 1;
foreach ($values['collaborators'] as $collab_key => $coll) {
// foreach ($coll as $field_key => $field_value) {
// if($field_value == ''){
// $human_field_name = $form['submitted']['collaborators'][$coll_key]['#title'] . " : " . $form['submitted']['collaborators'][$coll_key][$field_key]['#title'];
// $field_name = 'submitted][collaborators]['.$coll_key.']['.$field_key;
// // dsm($field_name, 'field_name');
// form_set_error($field_name, t('You must provide a value for the !name field.', array('!name'=>$human_field_name)));
// }
// }
$userinfo = array(
'mail' => $coll['e_mail_collab_'.$i],
'name' => user_password(),
'pass' => user_password(), // Generate password
// 'init' => $data['components']['username']['value'],
'status' => 0,
'access' => REQUEST_TIME,
'memo' => 'from webform',
);
$account = drupal_anonymous_user();
$account->is_new = TRUE;
user_save($account, $userinfo);
// module_invoke_all('user_insert', $edit, $account);
$i++;
}
}
*/
}
/**
* Implements hook_help().
*/
function materio_user_help($path, $arg) {
// dsm($path, 'path');
// dsm($arg, 'arg');
switch ($path) {
case 'node/%':
if($arg[1] == 11187 ){
global $user;
// dsm($user, 'user');
if(isset($user->roles[1])){ // anonyme
$message = t('Please create first a free account and join materio or log in with your existing account,<br />then we\'ll provide you our membership form.', array());
$content = '<p>' . $message . '</p>';
return $content;
}else if(isset($user->roles[2])){ // authentificated user (not utilisateur)
$content = '<h2>' . t('Welcome, you just joined materiO\' !') . '</h2>';
$frontlink = l(t('continue with basic'), '<front>');
$message = t('Now you can choose the membership that\'s right for you, or !link', array('!link'=>$frontlink));
$content .= '<p>' . $message . '</p>';
return $content;
}
}
}
}
/**
* Implements hook_block_view_alter().
*/
function materio_user_block_view_alter(&$data, $block) {
if( $block->module == "user" && $block->delta == 'login' && isset($data['subject']) ){
// dsm($block, 'block');
// dsm($data, 'data');
$data['subject'] = '<i class="icon-user"></i>' . '<span class="login">' . $data['subject'] . '</span>';
}
}
/**
* Define constants
*/
define('MATERIO_USER_CONFIRMED_USER_ROLE', 'Utilisateur'); // add role name here
/**
* Implement hook_user
*/
function _materio_user_user_update(&$edit, $account, $category){
// dsm($edit, 'edit');
// dsm($account, 'account');
// dsm($category, 'category');
// This is only fired when a user confirms their email address, logintoboggan style
if (isset($account->logintoboggan_email_validated) && $account->logintoboggan_email_validated == TRUE) {
$confirmed_rid = materio_user_get_role_by_name(MATERIO_USER_CONFIRMED_USER_ROLE);
$roles = $account->roles + array($confirmed_rid => MATERIO_USER_CONFIRMED_USER_ROLE);
// we have to do this to stop an infinite loop, and also to allow lower weighted modules to possibly do something here
$user = $account;
unset($user->logintoboggan_email_validated);
user_save($user, array('roles' => $roles));
drupal_go_to('user/'.$user->uid.'/edit');
}
}
/**
* Returns a role ID based on role name
*
* @param $name
* name of role to return
* @return
* (int) Role ID
*/
function materio_user_get_role_by_name($name) {
return array_search($name, user_roles());
}

View File

@ -0,0 +1,58 @@
<?php
function materio_user_registerblock(){
$return = array();
$block = block_load('materio_user','user_createaccount');
$return['block'] = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));
drupal_json_output($return);
}
function materio_user_loginandregisterblock(){
$return = array();
$block = block_load('materio_user','user_register');
$return['block'] = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));
drupal_json_output($return);
}
function materio_user_register_submit(){
$return = array();
$return['POST'] = $_POST;
$form_state = array( "values"=>$_POST);
drupal_form_submit($_POST['form_id'], $form_state);
// $return['form_state'] = $form_state;
$return['errors'] = form_get_errors();
if($return['errors']){
unset ($_SESSION['messages']['error']);
}else{
$messages = drupal_get_messages('status');
// $return['messages'] = $messages;
drupal_set_message(t("Congratulations, you juste created your free materiO' account, welcome !"), 'status');
foreach ($messages['status'] as $msg) {
drupal_set_message($msg, 'status');
}
}
// after registration user is automaticly logged in, thank's to login tobogan module
drupal_json_output($return);
}
function materio_user_login_submit(){
$return = array();
$return['POST'] = $_POST;
$form_state = array("values"=>$_POST);
drupal_form_submit($_POST['form_id'], $form_state);
$return['errors'] = form_get_errors();
if($return['errors'])
unset ($_SESSION['messages']['error']);
// if user-login form succed we retreive the user uid on $form_state, then we can effectively loggin the user
if($uid = $form_state['uid'])
user_login_submit(array(), $form_state);
drupal_json_output($return);
}

View File

@ -0,0 +1,25 @@
name = Materio User Rules
description = "Materio user rules generalist module"
; Core version (required)
core = 7.x
; Package name (see http://drupal.org/node/542202 for a list of names)
package = Materio
; PHP version requirement (optional)
; php = 5.2
; Loadable code files
; Module dependencies
dependencies[] = user
dependencies[] = logintoboggan
dependencies[] = simplenews
dependencies[] = rules
; Configuration page
; configure = admin/config/materiobasemod
; For further information about configuration options, see
; - http://drupal.org/node/542202

View File

@ -0,0 +1,44 @@
<?php
/**
* Implement hook_user()
*
*/
function materio_user_rules_user_update(&$edit, $account) {
if (!empty($account->logintoboggan_email_validated)) {
if($subscriber = simplenews_subscriber_load_by_mail($account->mail)){
foreach($subscriber->newsletter_subscription as $tid => $subscription){
$term = taxonomy_term_load($tid);
$subscriptions_text_array[] = $term->name;
$subscriptions_tids[] = $tid;
}
$subscriptions_text = implode(', ', $subscriptions_text_array);
$args = array(
'account' => $account,
'subscriptions_list' => $subscriptions_tids,
'subscriptions_text' => $subscriptions_text,
);
rules_invoke_event_by_args('materio_logintoboggan_validated', $args);
}
}
}
/**
* Implements hook_simplenews_unsubscribe_user().
*/
function materio_user_rules_simplenews_subscribe_user($subscriber, $subscription) {
if (!empty($subscriber->logintoboggan_email_validated)) {
$args = array(
'mail' => $subscriber->mail,
'tid' => $subscription->tid,
);
// rules_invoke_event_by_args('simplenews_rules_event_subscribe', $args);
}
}

View File

@ -0,0 +1,31 @@
<?php
/**
* Implement hook_rules_event_info().
* @ingroup rules
*/
function materio_user_rules_rules_event_info() {
return array(
'materio_logintoboggan_validated' => array(
'label' => t("a user is validated and subcribed to newsletter on registration."),
'group' => 'Materio',
'variables' => array(
'account' => array(
'type' => 'user',
'label' => t("The validated user's account"),
),
'subscriptions_list' => array(
'type' => 'list',
'label' => t("The Simplenews info from the account validated as a list of tid for looping"),
),
'subscriptions_text' => array(
'type' => 'text',
'label' => t("The Simplenews info from the account validated as a single text"),
),
),
),
);
}

View File

@ -0,0 +1,3 @@
<?php
$entity_view = entity_view('node', $items, 'teaser');
print render($entity_view);

View File

@ -0,0 +1,3 @@
<section id="didactique-page">
<?php print render(entity_view('node', $items, 'full')); ?>
</section>

View File

@ -0,0 +1,5 @@
<section class="bookmarks">
<?php $entity_view = entity_view('node', $bookmarks, $viewmode); ?>
<?php print render($entity_view); ?>
</section>

View File

@ -0,0 +1,19 @@
<div class="mylists">
<?php foreach ($lists as $name => $list): ?>
<section class="flag-list <?php print $list['list']->name; ?>">
<?php //dsm($list, 'list');?>
<h2 class="listname">
<span class="listname">
<?php print $list['list']->title.' ('.count($list['content']).')'; ?>
</span>
<a class="open-list" href="<?php print $list['list']->path; ?>">
<?php //print t('open this @name', array('@name'=>variable_get('flag_lists_name', 'list'))) ;?>
<i class="icon-resize-full"></i>
</a>
</h2>
<?php $content = $list['content']; ?>
<?php $entity_view = entity_view('node', $content, $viewmode); ?>
<div class="flaged <?php print $list['list']->name; ?>"> <?php print render($entity_view); ?> </div>
</section>
<?php endforeach; ?>
</div>

View File

@ -0,0 +1,9 @@
<?php //dsm($variables, '$variables'); ?>
<div class="materio-flags-list <?php print ' view-mode-' . $variables['view_mode'];?>" fid="<?php print $variables['fid']; ?>">
<div class="flaglist-items">
<p class="flaglist-infos"><?php print $list_count; ?></p>
<?php print render(entity_view('node', $items, $variables['view_mode'])); ?>
</div>
<?php print $pager; ?>
</div>

View File

@ -0,0 +1,39 @@
<section class="mylists">
<ul>
<?php if($flags): ?>
<?php foreach ($flags as $name => $flag): ?>
<?php //dsm($flag, 'flag') ;?>
<li class="flaglist <?php print $flag->name; ?>">
<?php print l($flag->title . '<span class="count">('.count($flag->flaged_content).')</span>', 'lists/'.$flag->fid, array('html'=>true,'attributes'=>array('class'=>array('open-list', $flag->name)))); ?>
<?php if(flag_lists_is_owner('edit', $flag->fid)): ?>
<?php
print l('<i class="icon-wrench"></i>',
'flags/lists/edit/'.$flag->fid,
array(
'html'=>true,
'attributes'=>array('class'=>array('edit-list', $flag->name)),
)
);
?>
<?php endif; ?>
</li>
<?php endforeach; ?>
<?php else: ?>
<?php
#create new list
$create_link = l(
'<i class="icon-plus"></i>&nbsp;<span>' . t('New @name', array('@name' => t(variable_get('flag_lists_name', 'list')))) . '</span>',
'flag-lists/add/materiau',
array(
'attributes' => array(
'class' => array('flag-lists-create'),
'title' => t('create a new @name.', array('@name'=>t(variable_get('flag_lists_name', 'list')))),
),
'html' => TRUE,
)
);
?>
<li class="flag-lists-create"><?php print $create_link; ?> </li>
<?php endif; ?>
</ul>
</section>

View File

@ -0,0 +1,19 @@
<?php
?>
<section class="materiobase-actuality">
<?php if($count): ?>
<p class="actualities-infos"><?php print $actualities_infos; ?></p>
<div class="actuality-items">
<?php $entity_view = entity_view('node', $items, $view_mode); ?>
<?php print render($entity_view); ?>
</div>
<div class="pager">
<?php print $pager; ?>
</div>
<?php else : ?>
<div class="actuality-no-items">
<h2><?php print t('There is now actuality for now.');?></h2>
</div>
<?php endif ;?>
</section>

View File

@ -0,0 +1,3 @@
<?php
print render($content);

View File

@ -0,0 +1,67 @@
<?php
/**
* @file
* Default theme implementation for displaying search results.
*
* This template collects each invocation of theme_search_result(). This and
* the child template are dependent to one another sharing the markup for
* definition lists.
*
* Note that modules and themes may implement their own search type and theme
* function completely bypassing this template.
*
* Available variables:
* - $result_count: Number of results.
* - $spellcheck: Possible spelling suggestions from Search spellcheck module.
* - $search_results: All results rendered as list items in a single HTML string.
* - $items: All results as it is rendered through search-result.tpl.php.
* - $search_performance: The number of results and how long the query took.
* - $sec: The number of seconds it took to run the query.
* - $pager: Row of control buttons for navigating between pages of results.
* - $index:
* - $keys: The keywords of the executed search.
* - $page_machine_name: Machine name of the current Search API Page.
*
* View Mode is set in the Search page settings. If you select
* "Themed as search results", then the child template will be used for
* theming the individual result. Any other view mode will bypass the
* child template.
*
* @see template_preprocess_search_api_page_results()
*/
?>
<?php //dsm($index, 'index'); ?>
<?php //dsm($search_performance, 'search_performance'); ?>
<?php //dsm($result_count, 'result_count'); ?>
<?php //if (!empty($result_count)) : ?>
<div class="materiobase-results <?php print ' view-mode-' . $variables['view_mode'];?>">
<?php //if ($result_count) : ?>
<?php if(!$perfascard): ?>
<p class="search-performance"><?php print render($search_performance); ?></P>
<?php endif; ?>
<?php //print render($spellcheck); ?>
<div class="search-results">
<?php if($perfascard): ?>
<article class="search-performance <?php print ' view-mode-' . $variables['view_mode'];?>">
<div class="inner">
<p><?php print render($search_performance); ?></P>
</div>
</article>
<?php endif; ?>
<?php //dsm($items, '$items'); ?>
<?php
// TODO: use cache system to gain in speed, view http://drupal.org/node/930760
?>
<?php if ($result_count) : ?>
<?php print render(entity_view($index->item_type, $items, $variables['view_mode'])); ?>
<?php endif; ?>
</div>
<?php print $pager; ?>
<?php //else : ?>
<!-- <p class="search-noresults"><?php print t('Your search yielded no results.');?></p> -->
<?php //endif; ?>
</div>
<?php //endif; ?>

View File

@ -0,0 +1,5 @@
<div class="inner">
<?php print render($searchform); ?>
</div>

View File

@ -0,0 +1,3 @@
<?php
print $content;

View File

@ -0,0 +1 @@
<p>TODO</p>

View File

@ -0,0 +1,65 @@
<table style="margin: 0; border-collapse: collapse;" width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff; padding:0 0 5px 0;" align="left">
<table style="margin: 0; border-collapse: collapse;" width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff; padding: 0;" align="left">
<img src="/sites/default/files/uploaderuneimage.png" width="600" height="400">
</td>
</tr>
</tbody>
</table>
<table style="margin: 0 0 0 10px; border-collapse: collapse; color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff;">
<tbody>
<tr>
<td style="vertical-align: top; padding: 5px 0;" width="580">
<table style="border-collapse: collapse; width: 565px; color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff;" width="565" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="padding: 5px 0 5px 5px; line-height: normal; color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff;">
<p style="color: #444444; text-align: left; ;margin: 0 0 10px; line-height: 1.3em;">
<span style="color: #444444; font-family: arial, helvetica, sans-serif;">
<strong>
ZE DAILY MATERIO'
</strong>
</span>
</p>
<p style="color: #444444; ;margin: 0 0 10px; line-height: 1.3em;">
<strong>
le titre en fr
</strong>
<br>
Toute une série de matières recyclées sous vos pieds, car ces tapis sont tissés avec des chambres à air usagées, des papiers de bonbons minutieusement filés, de vieux journaux et magazines tressés ou d'autres matières recyclées surprenantes. Certains tapis de cette gamme peuvent même aller à l'extérieur.
</p>
<div>
&nbsp;
</div>
<p style="color: #444444; ;margin: 0 0 10px; line-height: 1.3em;">
<span style="color: #696969;">
<em>
<strong>
The english title&nbsp;
</strong>
</em>
</span>
<br>
<span style="color: #808080;">
<em>
A wide range of beautiful carpets made out of surprising recycled materials: recycled candy wrappers, recycled tires and bike tubes, different recycled fibers and recycled newspaper! Some of them can even be used outside.
</em>
</span>
</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>

View File

@ -0,0 +1,65 @@
<table style="margin: 0; border-collapse: collapse;" width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff; padding:0 0 5px 0;" align="left">
<table style="margin: 0; border-collapse: collapse;" width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff; padding: 0;" align="left">
<img src="/sites/default/files/uploaderuneimage.png" width="600" height="400">
</td>
</tr>
</tbody>
</table>
<table style="margin: 0 0 0 10px; border-collapse: collapse; color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff;">
<tbody>
<tr>
<td style="vertical-align: top; padding: 5px 0;" width="580">
<table style="border-collapse: collapse; width: 565px; color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff;" width="565" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="padding: 5px 0 5px 5px; line-height: normal; color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff;">
<p style="color: #444444; text-align: left; ;margin: 0 0 10px; line-height: 1.3em;">
<span style="color: #444444; font-family: arial, helvetica, sans-serif;">
<strong>
ZE DAILY MATERIO'
</strong>
</span>
</p>
<p style="color: #444444; ;margin: 0 0 10px; line-height: 1.3em;">
<strong>
le titre en fr
</strong>
<br>
Toute une série de matières recyclées sous vos pieds, car ces tapis sont tissés avec des chambres à air usagées, des papiers de bonbons minutieusement filés, de vieux journaux et magazines tressés ou d'autres matières recyclées surprenantes. Certains tapis de cette gamme peuvent même aller à l'extérieur.
</p>
<div>
&nbsp;
</div>
<p style="color: #444444; ;margin: 0 0 10px; line-height: 1.3em;">
<span style="color: #696969;">
<em>
<strong>
The english title&nbsp;
</strong>
</em>
</span>
<br>
<span style="color: #808080;">
<em>
A wide range of beautiful carpets made out of surprising recycled materials: recycled candy wrappers, recycled tires and bike tubes, different recycled fibers and recycled newspaper! Some of them can even be used outside.
</em>
</span>
</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>