function epsacrop_dialog in EPSA Crop - Image Cropping 7.2
Same name and namespace in other branches
- 8.2 epsacrop.module \epsacrop_dialog()
- 6.2 epsacrop.module \epsacrop_dialog()
- 6 epsacrop.module \epsacrop_dialog()
epsacrop_dialog function.
@access public
Parameters
string $entity_name:
string $field_name:
string $bundle:
int $fid:
Return value
void
1 string reference to 'epsacrop_dialog'
- epsacrop_menu in ./
epsacrop.module - Implements hook_menu.
File
- ./
epsacrop.module, line 114 - The main file of module
Code
function epsacrop_dialog($entity_name, $field_name, $bundle, $fid) {
$out = '';
//@TODO: If a method is added to determine if the image is used elsewhere (or number of instances), add that condition for the message
//related issue: http://drupal.org/node/1352722
if (module_exists('media')) {
$out .= '<p>For convenience, cropping applies to <strong>all</strong> current and future content which uses this image. (If the image is from the library, changing the cropping will affect all existing content which uses the image.)</p>';
}
$data = _epsacrop_get_coords_from_fid($fid);
if (!is_string($data)) {
$data = drupal_json_encode((object) $data);
$data = check_plain($data);
}
$out .= '<div class="epsacrop-global" data-token="' . drupal_get_token('epsacrop-put-' . $fid) . '" data-coordinates="' . urlencode($data) . '">' . "\n";
$out .= '<div class="epsacrop-image-crop">' . "\n";
$out .= '<img id="epsacrop-target" />' . "\n";
$out .= '</div>' . "\n";
$out .= '<div class="epsacrop-presets-menu">' . "\n";
$out .= '<ul class="epsacrop-presets-menu-ul">' . "\n";
$i = 0;
if ($entity_name == 'all' && $field_name == 'all' && $bundle == 'all') {
//When on the file edit page, there is no entity_name, field_name or bundle. So make all styles available for editing
$all_styles = array_keys(_epsacrop_load_styles());
$styles = array(
'styles' => array_combine($all_styles, $all_styles),
);
}
else {
$styles = _epsacrop_load_styles_by_instance($entity_name, $field_name, $bundle);
}
foreach ($styles['styles'] as $style_name) {
$style = _epsacrop_load_style($style_name);
$effect = _epsacrop_get_effect($style);
$effect = current($effect);
$id = 'epsacrop-' . $style_name;
$name = is_array($style) && !empty($style['label']) ? $style['label'] : $style_name;
$out .= '<li class="epsacrop-presets-menu-li"><a data-bgcolor="' . $effect['data']['jcrop_settings']['bgcolor'] . '" data-bgopacity="' . $effect['data']['jcrop_settings']['bgopacity'] . '" data-aspect-ratio="' . $effect['data']['jcrop_settings']['aspect_ratio'] . '" id="' . $id . '" href="javascript:Drupal.EPSACrop.crop(\'' . $id . '\');" rel="' . $effect['data']['width'] . 'x' . $effect['data']['height'] . '"' . ($i++ == 0 ? ' class="selected"' : '') . '>' . $name . '</a></li>';
}
$out .= '</ul>' . "\n";
$out .= '</div>' . "\n";
$out .= '<br style="clear:both;" />' . "\n";
$out .= '</div>' . "\n";
$GLOBALS['devel_shutdown'] = FALSE;
echo $out;
drupal_exit();
}