コード例 #1
0
ファイル: tinymce.php プロジェクト: dregula/Annotum
/**
 * Popup Dialog for equation editor in the tinyMCE
 */
function anno_popup_equations()
{
    ?>
<div id="anno-popup-equations" class="anno-mce-popup">
	<form id="anno-tinymce-equations-form" class="" tabindex="-1">
		<div class="anno-mce-popup-fields">
			<div class="equation-edit-details">
				<label for="equation-alttext">
					<div><?php 
    _ex('Alt Text', 'input label', 'anno');
    ?>
</div>
					<input name="alt_text" type="text" id="equation-alttext" />
				</label>
				<label for="equation-description">
					<div><?php 
    _ex('Description', 'input label', 'anno');
    ?>
</div>
					<textarea name="description" id="equation-description"></textarea>
				</label>
			</div>
			<fieldset class="equation-display">
				<legend><?php 
    _ex('Display', 'legend', 'anno');
    ?>
</legend>
				<label for="equation-display-figure" class="radio">
					<input type="radio" value="figure" name="display" class="equation-display-selection equation-display-figure" id="equation-display-figure"<?php 
    checked(true, true, true);
    ?>
 />
					<span><?php 
    _ex('Display as Figure', 'input label', 'anno');
    ?>
</span>
				</label>
				<label for="equation-display-inline" class="radio">
					<input type="radio" value="inline" name="display" class="equation-display-selection equation-display-inline" id="equation-display-inline" />
					<span><?php 
    _ex('Display Inline', 'input label', 'anno');
    ?>
</span>
				</label>
				<div id="equation-figure-details">
					<label for="equation-label">
						<span><?php 
    _ex('Label', 'input label', 'anno');
    ?>
</span>
						<input type="text" name="label" id="equation-label" />
					</label>
					<label for="equation-caption">
						<span><?php 
    _ex('Caption', 'input label', 'anno');
    ?>
</span>
						<textarea id="equation-caption" name="caption"></textarea>
					</label>
				</div>
			</fieldset>
		</div>
		<div class="anno-mce-popup-footer">
			<?php 
    _anno_popup_submit_button('anno-equations-insert', _x('Insert', 'button value', 'anno'));
    ?>
		</div>
	</form>
</div>
<?php 
}
コード例 #2
0
function anno_popup_images_row_edit($attachment)
{
    $img_url = wp_get_attachment_image_src($attachment->ID, 'anno_img_edit');
    $description = $attachment->post_content;
    $caption = $attachment->post_excerpt;
    $alt_text = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
    $display = get_post_meta($attachment->ID, '_anno_attachment_image_display', true);
    if (empty($display)) {
        $display = 'figure';
    }
    //@TODO worth storing all this data in a single meta row as a serialized array
    $label = get_post_meta($attachment->ID, '_anno_attachment_image_label', true);
    $copyright_statement = get_post_meta($attachment->ID, '_anno_attachment_image_copyright_statement', true);
    $copyright_holder = get_post_meta($attachment->ID, '_anno_attachment_image_copyright_holder', true);
    $license = get_post_meta($attachment->ID, '_anno_attachment_image_license', true);
    $url = get_post_meta($attachment->ID, '_anno_attachment_image_url', true);
    $file_url = wp_get_attachment_url($attachment->ID);
    $link = get_attachment_link($attachment->ID);
    $img_size = get_post_meta($attachment->ID, '_anno_attachment_image_size', true);
    if (!$img_size) {
        $img_size = 'thumbnail';
    }
    ?>
			<tr>
				<td class="img-edit-td" colspan="3">
					<form id="<?php 
    echo esc_attr('img-edit-' . $attachment->ID);
    ?>
" class="anno-img-edit">
						<div class="img-edit-details">
							<img src="<?php 
    echo esc_url($img_url[0]);
    ?>
" alt="<?php 
    echo esc_attr($attachment->post_title);
    ?>
" class="img-list-img" />
							<label for="<?php 
    echo esc_attr('img-alttext-' . $attachment->ID);
    ?>
">
								<div><?php 
    _ex('Alt Text', 'input label', 'anno');
    ?>
</div>
								<input name="alt_text" type="text" id="<?php 
    echo esc_attr('img-alttext-' . $attachment->ID);
    ?>
" value="<?php 
    echo esc_attr($alt_text);
    ?>
" />
							</label>
							<label for="<?php 
    echo esc_attr('img-description-' . $attachment->ID);
    ?>
">
								<div><?php 
    _ex('Description', 'input label', 'anno');
    ?>
</div>
								<textarea name="description" id="<?php 
    echo esc_attr('img-description-' . $attachment->ID);
    ?>
"><?php 
    echo esc_textarea($description);
    ?>
</textarea>
							</label>
						</div>
<?php 
    /*						@TODO Find a way to maintain wrapping URL data while adhering to DTD
    						<div class="img-url-input">
    							<label for="<?php echo esc_attr('img-url-'.$attachment->ID); ?>">
    								<input id="<?php echo esc_attr('img-url-'.$attachment->ID); ?>" type="text" name="url" value="<?php echo esc_attr($url); ?>" /><span><?php _e('URL', 'anno'); ?></span>
    							</label>
    							<div id="<?php echo esc_attr('img-url-buttons-'.$attachment->ID); ?>" class="img-url-buttons">
    								<button type="button" class="button" title=""><?php _e('None', 'anno'); ?></button>
    								<button type="button" class="button" title="<?php echo esc_attr($file_url); ?>"> <?php _e('File URL', 'anno'); ?></button>
    								<button type="button" class="button" title="<?php echo esc_attr($link); ?>"><?php _e('Attachment Post URL', 'anno'); ?></button>
    							</div>
    						</div>
    */
    ?>
						<fieldset class="img-display">
							<legend><?php 
    _ex('Display', 'legend', 'anno');
    ?>
</legend>
							<label for="<?php 
    echo esc_attr('img-display-figure-' . $attachment->ID);
    ?>
" class="radio">
								<input type="radio" value="figure" name="display" class="img-display-selection img-display-figure" id="<?php 
    echo esc_attr('img-display-figure-' . $attachment->ID);
    ?>
"<?php 
    checked($display, 'figure', true);
    ?>
 />
								<span><?php 
    _ex('Display as Figure', 'input label', 'anno');
    ?>
</span>
							</label>
							<label for="<?php 
    echo esc_attr('img-display-inline-' . $attachment->ID);
    ?>
" class="radio">
								<input type="radio" value="inline" name="display" class="img-display-selection img-display-inline" id="<?php 
    echo esc_attr('img-display-inline-' . $attachment->ID);
    ?>
"<?php 
    checked($display, 'inline', true);
    ?>
 />
								<span><?php 
    _ex('Display Inline', 'input label', 'anno');
    ?>
</span>
							</label>
							<div id="<?php 
    echo esc_attr('img-figure-details-' . $attachment->ID);
    ?>
">
								<label for="<?php 
    echo esc_attr('img-label-' . $attachment->ID);
    ?>
">
									<span><?php 
    _ex('Label', 'input label', 'anno');
    ?>
</span>
									<input type="text" name="label" id="<?php 
    echo esc_attr('img-label-' . $attachment->ID);
    ?>
" value="<?php 
    echo esc_attr($label);
    ?>
" />
								</label>
								<label for="<?php 
    echo esc_attr('img-caption-' . $attachment->ID);
    ?>
">
									<span><?php 
    _ex('Caption', 'input label', 'anno');
    ?>
</span>
									<textarea id="<?php 
    echo esc_attr('img-caption-' . $attachment->ID);
    ?>
" name="caption"><?php 
    echo esc_textarea($caption);
    ?>
</textarea>
								</label>
							</div>
						</fieldset>
						<fieldset>
							<legend><?php 
    _ex('Permissions', 'legend', 'anno');
    ?>
</legend>
							<label for="<?php 
    echo esc_attr('img-copystatement-' . $attachment->ID);
    ?>
">
								<span><?php 
    _ex('Copyright Statement', 'input label', 'anno');
    ?>
</span>
								<input type="text" name="copyright_statement" id="<?php 
    echo esc_attr('img-copystatement-' . $attachment->ID);
    ?>
" value="<?php 
    echo esc_attr($copyright_statement);
    ?>
" />
							</label>
							<label for="<?php 
    echo esc_attr('img-copyholder-' . $attachment->ID);
    ?>
">
								<span><?php 
    _ex('Copyright Holder', 'input label', 'anno');
    ?>
</span>
								<input type="text" name="copyright_holder" id="<?php 
    echo esc_attr('img-copyholder-' . $attachment->ID);
    ?>
" value="<?php 
    echo esc_attr($copyright_holder);
    ?>
" />
							</label>
							<label for="<?php 
    echo esc_attr('img-license-' . $attachment->ID);
    ?>
">
								<span><?php 
    _ex('License', 'input label', 'anno');
    ?>
</span>
								<input type="text" name="license" id="<?php 
    echo esc_attr('img-license-' . $attachment->ID);
    ?>
" value="<?php 
    echo esc_attr($license);
    ?>
" />
							</label>
						</fieldset>
						<fieldset class="img-sizes">
							<legend><?php 
    _ex('Size', 'legend for image size', 'anno');
    ?>
</legend>
							<?php 
    $sizes = array('thumbnail' => _x('Thumbnail', 'size label for images', 'anno'), 'medium' => _x('Medium', 'size label for images', 'anno'), 'large' => _x('Large', 'size label for images', 'anno'));
    // For small images, we won't have any image sizes displayed.
    $size_displayed = false;
    foreach ($sizes as $size_key => $size_label) {
        $downsize = image_downsize($attachment->ID, $size_key);
        $enabled = $downsize[3];
        if ($enabled) {
            $img_size_url = wp_get_attachment_image_src($attachment->ID, $size_key);
            $img_size_url = $img_size_url[0];
            $size_displayed = true;
        } else {
            $img_size_url = '';
        }
        if (!empty($img_size_url)) {
            ?>
									<label for="<?php 
            echo esc_attr('img-size-' . $size_key . '-' . $attachment->ID);
            ?>
">
										<input type="radio" name="size" id="<?php 
            echo esc_attr('img-size-' . $size_key . '-' . $attachment->ID);
            ?>
" value="<?php 
            echo esc_attr($size_key);
            ?>
" data-url="<?php 
            echo esc_attr($img_size_url);
            ?>
"<?php 
            checked($size_key, $img_size, true);
            ?>
/> <?php 
            echo esc_html($size_label);
            ?>
									</label>
<?php 
        }
    }
    // No size data displayed because the original image was too small
    if (!$size_displayed) {
        $img_size_url = wp_get_attachment_image_src($attachment->ID, 'full');
        $img_size_url = $img_size_url[0];
        if ($img_size_url) {
            ?>
										
										<label for="<?php 
            echo esc_attr('img-size-full-' . $attachment->ID);
            ?>
">
											<input type="radio" name="size" id="<?php 
            echo esc_attr('img-size-full-' . $attachment->ID);
            ?>
" value="full" data-url="<?php 
            echo esc_attr($img_size_url);
            ?>
"<?php 
            checked(true, true, true);
            ?>
 /> <?php 
            _ex('Full', 'size label for images', 'anno');
            ?>
										</label>
<?php 
        }
    }
    ?>
						</fieldset>
<?php 
    if (anno_current_user_can_edit()) {
        ?>
						<div class="anno-mce-popup-footer">
							<?php 
        _anno_popup_submit_button('anno-image-save', _x('Save', 'button value', 'anno'), 'submit');
        ?>
							<input type="button" id="<?php 
        echo esc_attr('anno-image-insert-' . $attachment->ID);
        ?>
" class="anno-image-insert button" value="<?php 
        _ex('Insert', 'button value', 'anno');
        ?>
" />
							<input type="hidden" name="action" value="anno-img-save" />
							<input type="hidden" name="attachment_id" value="<?php 
        echo esc_attr($attachment->ID);
        ?>
" />
						</div>
<?php 
    }
    ?>
						
					</form>
				</td>
			</tr>
<?php 
}