Created
October 3, 2016 15:06
-
-
Save cyberlex404/77db0761e65babfebbdf8773b2b467a4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Created by PhpStorm. | |
* User: Lex | |
* Date: 20.10.2015 | |
* Time: 9:05 | |
*/ | |
/** | |
* This plugin array is more or less self documenting | |
*/ | |
$plugin = array( | |
'title' => t('Profile login'), | |
'single' => TRUE, | |
'category' => array(t('User'), -9), | |
'edit form' => 'bras_profile_login_edit_form', | |
'render callback' => 'bras_profile_login_render', | |
'required context' => new ctools_context_required(t('User'), 'user'), | |
'defaults' => array( | |
//'style_name' => 'profile_circle_small', | |
'link' => TRUE, | |
), | |
'icon' => 'user-plugin.png', | |
'admin info' => 'bras_profile_login_admin_info', | |
); | |
/** | |
* Run-time rendering of the body of the block (content type) | |
* See ctools_plugin_examples for more advanced info | |
*/ | |
function bras_profile_login_render($subtype, $conf, $args, $context) { | |
ctools_include('ajax'); | |
ctools_include('modal'); | |
ctools_modal_add_js(); | |
$login_style = array( | |
'login-modal-style' => array( | |
'modalSize' => array( | |
'type' => 'fixed', | |
'width' => 500, | |
'height' => 300, | |
'addWidth' => 10, | |
'addHeight' => 10, | |
'contentRight' => 0, | |
'contentBottom' => 0, | |
), | |
'modalOptions' => array( | |
'opacity' => .6, | |
'background-color' => '#000', | |
), | |
'animation' => 'fadeIn', | |
'modalTheme' => 'login_modal', | |
// Customize the AJAX throbber like so: | |
// This function assumes the images are inside the module directory's "images" | |
// directory: | |
// ctools_image_path($image, $module = 'ctools', $dir = 'images') | |
'throbber' => theme('image', array('path' => ctools_image_path('ajax-loader.gif', 'bras_profile'), 'alt' => t('Loading...'), 'title' => t('Loading'))), | |
'closeImage' => theme('image', array('path' => ctools_image_path('modal-close.png', 'bras_profile'), 'alt' => t('Close window'), 'title' => t('Close window'))), | |
), | |
); | |
// Add the settings array defined above to Drupal 7's JS settings: | |
drupal_add_js($login_style, 'setting'); | |
// The function below assumes the happy.js file resides in [module_dir]/js | |
ctools_add_js('login-style', 'bras_profile'); | |
$str = ''; | |
$link = '<span><i class="fa fa-sign-in"></i> Вход</span>'; | |
if(user_is_anonymous()) { | |
$str = ''; | |
$str .= l($link, "my/login/nojs", array( | |
'attributes' => array( | |
'class' => array( | |
'ctools-use-modal', | |
'ctools-modal-login-modal-style' | |
) | |
), | |
'html' => TRUE, | |
) | |
); | |
} | |
$block = new stdClass(); | |
$block->content = '<div class="bras-login-link">' . $str . '</div>'; | |
return $block; | |
} | |
/** | |
* 'Edit form' callback for the content type. | |
*/ | |
function bras_profile_login_edit_form($form, &$form_state) { | |
$conf = $form_state['conf']; | |
$styles_param = array(); | |
$styles = image_styles(); | |
foreach($styles as $key => $value){ | |
$name = $value['name']; | |
$label = $value['label']; | |
$styles_param[$name] = $label; | |
} | |
$form['image_style'] = array( | |
'#type' => 'select', | |
'#title' => t('Image style'), | |
'#options' => $styles_param, | |
'#default_value' => empty($conf['image_style']) ? 'profile_circle_small' :$conf['image_style'], | |
// '#description' => t('Set this to <em>Yes</em> if you would like this category to be selected by default.'), | |
); | |
$form['link'] = array( | |
'#type' => 'checkbox', | |
'#title' => t('Link profile'), | |
'#default_value' => $conf['link'], | |
); | |
// | |
// no submit | |
return $form; | |
} | |
/** | |
* Submit function, note anything in the formstate[conf] automatically gets saved | |
*/ | |
function bras_profile_login_edit_form_submit(&$form, &$form_state) { | |
$form_state['conf']['image_style'] = $form_state['values']['image_style']; | |
$form_state['conf']['link'] = $form_state['values']['link']; | |
} | |
/** | |
3 * 'admin info' callback for panel pane. | |
4 */ | |
function bras_profile_login_admin_info($subtype, $conf, $contexts) { | |
if (!empty($conf)) { | |
$block = new stdClass; | |
$block->title = $conf['override_title'] ? $conf['override_title_text'] : ''; | |
$block->content = t('<em>Image style:</em> <b>@image_style</b>; <em>Link:</em> <b>@link</b>.', array( | |
'@image_style' => $conf['image_style'], | |
'@link' => $conf['link'] ? 'ok': 'no link', | |
)); | |
return $block; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment