|
@@ -61,42 +61,48 @@ function edlp_studio_node_view(array &$build, \Drupal\Core\Entity\EntityInterfac
|
|
// dpm($entity->id());
|
|
// dpm($entity->id());
|
|
$user = \Drupal::currentUser();
|
|
$user = \Drupal::currentUser();
|
|
// dpm($user);
|
|
// dpm($user);
|
|
|
|
+ // check if user loged in ? no -> popup message : yes -> links
|
|
if($user->id() == 0){
|
|
if($user->id() == 0){
|
|
- // // TODO: check if user loged in ? yes -> links : no : popup message
|
|
|
|
- // $action = 'add';
|
|
|
|
- }
|
|
|
|
- // else{
|
|
|
|
- // // TODO: check if node already in chutier ? no -> add link : yes -> remove link
|
|
|
|
- // // use getUserChutiersContents() from \Drupal\edlp_studio\ChutierInterface
|
|
|
|
- // $contents = Chutier::getUserChutiersContents($user->id());
|
|
|
|
- // dpm($contents);
|
|
|
|
- // if(array_search($entity->id(), $contents) === false){
|
|
|
|
- // $action = 'add';
|
|
|
|
- // }else{
|
|
|
|
- // $action = 'remove';
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // $args = array(
|
|
|
|
- // 'action'=>$action,
|
|
|
|
- // 'id'=>$entity->id()
|
|
|
|
- // );
|
|
|
|
- // $url = Url::fromRoute('edlp_studio.chutier_controller_ajax_add_content', $args, array(
|
|
|
|
- // 'attributes' => array(
|
|
|
|
- // 'class' => ['chutier-link','chutier-ajax-link'],
|
|
|
|
- // 'action' => $action,
|
|
|
|
- // 'target_id' => $entity->id(),
|
|
|
|
- // )
|
|
|
|
- // ));
|
|
|
|
- $url = Chutier::getActionsUrl($entity->id(), $user->id());
|
|
|
|
- $build['chutier_actions'] = array(
|
|
|
|
- '#title' => t("Chutier."),
|
|
|
|
- '#type' => 'link',
|
|
|
|
- '#url' => $url,
|
|
|
|
- '#options'=>array(
|
|
|
|
- 'attributes' => array(
|
|
|
|
- 'data-drupal-link-system-path' => $url->getInternalPath()
|
|
|
|
|
|
+ $build['chutier_actions'] = array(
|
|
|
|
+ '#type' => 'container',
|
|
|
|
+ '#attributes' => array(
|
|
|
|
+ 'class' => array('chutier-icon', 'not-logedin')
|
|
|
|
+ ),
|
|
|
|
+ "popup"=>array(
|
|
|
|
+ '#type'=>'container',
|
|
|
|
+ '#attributes' => array(
|
|
|
|
+ 'class' => array('popup')
|
|
|
|
+ ),
|
|
|
|
+ "content"=>array(
|
|
|
|
+ '#type'=>'container',
|
|
|
|
+ '#attributes' => array(
|
|
|
|
+ 'class' => array('inner')
|
|
|
|
+ ),
|
|
|
|
+ 'text'=>array(
|
|
|
|
+ '#prefix'=>'<p>',
|
|
|
|
+ '#markup'=>t('Le Studio rassemble vos documents favoris.Il permet de les sauvgarder et de les agencer en compositions.'),
|
|
|
|
+ '#suffix'=>'</p>'
|
|
|
|
+ ),
|
|
|
|
+ 'links'=>array(
|
|
|
|
+ '#prefix'=>'<p>',
|
|
|
|
+ '#markup'=>'todo: login link',
|
|
|
|
+ '#suffix'=>'</p>'
|
|
|
|
+ )
|
|
|
|
+ )
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+ }else{
|
|
|
|
+ // TODO: check if user has permission 'use chutier'
|
|
|
|
+ $url = Chutier::getActionsUrl($entity->id(), $user->id());
|
|
|
|
+ $build['chutier_actions'] = array(
|
|
|
|
+ '#type' => 'link',
|
|
|
|
+ '#url' => $url,
|
|
|
|
+ '#options'=>array(
|
|
|
|
+ 'attributes' => array(
|
|
|
|
+ 'data-drupal-link-system-path' => $url->getInternalPath()
|
|
|
|
+ )
|
|
)
|
|
)
|
|
- )
|
|
|
|
- );
|
|
|
|
|
|
+ );
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|