/**
 * Inserts the submitted properties of uploaded media items
 *
 * @return array    array('image_id') holding the last created thumbnail for immediate processing
 *
 */
function serendipity_parsePropertyForm()
{
    global $serendipity;
    if (!is_array($serendipity['POST']['mediaProperties'])) {
        return false;
    }
    serendipity_checkPropertyAccess($serendipity['POST']['mediaProperties'], $serendipity['POST']['mediaKeywords'], 'write');
    foreach ($serendipity['POST']['mediaProperties'] as $id => $media) {
        serendipity_insertMediaProperty('base_property', '', $media['image_id'], $media);
        $s9y_img = $media['internal'];
        $s9y_img['image_id'] = $media['image_id'];
        serendipity_prepareMedia($s9y_img);
        $s9y_img['metadata'] =& serendipity_getMetaData($s9y_img['realfile'], $s9y_img['header']);
        serendipity_insertMediaProperty('base_metadata', 'ALL', $media['image_id'], $s9y_img['metadata']);
        $s9y_img['hidden'] = array('author' => $serendipity['serendipityUser'], 'authorid' => $serendipity['authorid']);
        serendipity_insertMediaProperty('base_hidden', '', $media['image_id'], $s9y_img['hidden']);
        if ($serendipity['POST']['oldDir'][$id] != $serendipity['POST']['newDir'][$id]) {
            serendipity_moveMediaDirectory(serendipity_uploadSecure($serendipity['POST']['oldDir'][$id]), serendipity_uploadSecure($serendipity['POST']['newDir'][$id]), 'filedir', $media['image_id']);
        }
    }
    if (is_array($serendipity['POST']['mediaKeywords'])) {
        foreach ($serendipity['POST']['mediaKeywords'] as $id => $keywords) {
            serendipity_insertMediaProperty('base_keyword', '', $serendipity['POST']['mediaProperties'][$id]['image_id'], $keywords);
        }
    }
    $array = array('image_id' => $serendipity['POST']['mediaProperties'][0]['image_id']);
    return $array;
}
Example #2
0
        ?>
<br />
        <input name="SAVE" value="<?php 
        echo DELETE_DIRECTORY;
        ?>
" class="serendipityPrettyButton input_button" type="submit" />
    </div>
    </form>

<?php 
        break;
    case 'directoryDoCreate':
        if (!serendipity_checkFormToken() || !serendipity_checkPermission('adminImagesDirectories')) {
            return;
        }
        $new_dir = serendipity_uploadSecure($serendipity['POST']['parent'] . '/' . $serendipity['POST']['name'], true);
        $new_dir = str_replace(array('..', '//'), array('', '/'), $new_dir);
        $nd = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $new_dir;
        serendipity_plugin_api::hook_event('backend_directory_create', $nd);
        /* TODO: check if directory already exist */
        if (is_dir($nd) || @mkdir($nd)) {
            printf(DIRECTORY_CREATED, $serendipity['POST']['name']);
            @umask(00);
            @chmod($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $new_dir, 0777);
            // Apply parent ACL to new child.
            $array_parent_read = serendipity_ACLGet(0, 'directory', 'read', $serendipity['POST']['parent']);
            $array_parent_write = serendipity_ACLGet(0, 'directory', 'write', $serendipity['POST']['parent']);
            if (!is_array($array_parent_read) || count($array_parent_read) < 1) {
                $parent_read = array(0);
            } else {
                $parent_read = array_keys($array_parent_read);
Example #3
0
     break;
 case 'directoryDelete':
     if (!serendipity_checkPermission('adminImagesDirectories')) {
         return;
     }
     $data['case_directoryDelete'] = true;
     $data['dir'] = serendipity_specialchars($serendipity['GET']['dir']);
     $data['formtoken'] = serendipity_setFormToken();
     $data['basename_dir'] = basename(serendipity_specialchars($serendipity['GET']['dir']));
     break;
 case 'directoryDoCreate':
     if (!serendipity_checkFormToken() || !serendipity_checkPermission('adminImagesDirectories')) {
         return;
     }
     $data['case_directoryDoCreate'] = true;
     $new_dir = serendipity_uploadSecure($serendipity['POST']['parent'] . '/' . serendipity_makeFilename($serendipity['POST']['name']), true);
     $new_dir = str_replace(array('..', '//'), array('', '/'), $new_dir);
     $nd = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $new_dir;
     serendipity_plugin_api::hook_event('backend_directory_create', $nd);
     /* TODO: check if directory already exist */
     if (is_dir($nd) || @mkdir($nd)) {
         $data['print_DIRECTORY_CREATED'] = sprintf(DIRECTORY_CREATED, $serendipity['POST']['name']);
         @umask(00);
         @chmod($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $new_dir, 0777);
         // Apply parent ACL to new child.
         $array_parent_read = serendipity_ACLGet(0, 'directory', 'read', $serendipity['POST']['parent']);
         $array_parent_write = serendipity_ACLGet(0, 'directory', 'write', $serendipity['POST']['parent']);
         if (!is_array($array_parent_read) || count($array_parent_read) < 1) {
             $parent_read = array(0);
         } else {
             $parent_read = array_keys($array_parent_read);
function cpg_displayImageList($page = 0, $lineBreak = NULL, $manage = false, $url = NULL)
{
    global $serendipity;
    global $CPG;
    $album = isset($CPG['album']) ? $CPG['album'] : NULL;
    if ($album == -1) {
        $album = NULL;
    }
    $sort_row_interval = array(8, 16, 50, 100);
    $sort_order = array('ctime' => 'Date', 'owner_id' => 'Owner', 'pid' => 'ID');
    $perPage = isset($CPG['sortorder']['perpage']) ? $CPG['sortorder']['perpage'] : $sort_row_interval[1];
    $start = ($page - 1) * $perPage;
    $order = 'ctime DESC';
    if (isset($CPG['sortorder']['order']) && isset($CPG['sortorder']['order'])) {
        $order = $CPG['sortorder']['order'] . ' ' . $CPG['sortorder']['ordermode'];
    }
    $images = cpg_getImages($totalImages, $start, $perPage, $album, $order, $serendipity['thumbSize']);
    $albums = cpg_getAlbums();
    $extraParams = '';
    $importParams = array('adminModule', 'htmltarget', 'filename_only', 'textarea');
    foreach ($importParams as $importParam) {
        if (isset($CPG[$importParam])) {
            $extraParams .= $importParam . '=' . $CPG[$importParam] . '&amp;';
        }
    }
    if (isset($CPG['only_path']) && !empty($CPG['only_path'])) {
        $extraParams .= 'only_path=' . $CPG['only_path'] . '&amp;';
        serendipity_uploadSecure($CPG['only_path'], true);
    }
    foreach ((array) $CPG['sortorder'] as $k => $v) {
        $extraParams .= 'sortorder[' . $k . ']=' . $v . '&amp;';
    }
    $extraParams .= 'album=' . (isset($album) ? $album : -1) . '&amp;';
    if (is_null($lineBreak)) {
        $lineBreak = floor(750 / ($serendipity['thumbSize'] + 20));
    }
    $link = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/plugin/' . CPG_EVENT . '&amp;';
    $left = '<input type="button" value="&lt;&lt;&lt;" onclick="location.href=\'' . $link . $extraParams . 'page=' . ($page - 1) . '\';" ' . ($start <= 0 ? 'disabled' : '') . '>' . "\n";
    $right = '<input type="button" value="&gt;&gt;&gt;" onclick="location.href=\'' . $link . $extraParams . 'page=' . ($page + 1) . '\';" ' . ($totalImages <= $start + $perPage ? 'disabled' : '') . '>' . "\n";
    //    $left  = '<input type="button" value="&lt;&lt;&lt;" onclick="location.href=\'?/plugin/' . CPG_EVENT . '&'. $extraParams .'page=' . ($page-1) . '\';" '. (($start <= 0) ? 'disabled' : '') .'>' . "\n";
    //    $right = '<input type="button" value="&gt;&gt;&gt;" onclick="location.href=\'?/plugin/' . CPG_EVENT . '&'. $extraParams .'page=' . ($page+1) . '\';" '. (($totalImages <= $start+$perPage) ? 'disabled' : '') .'>' . "\n";
    ?>

<style type="text/css">
<!--

.cpg_thumbnail_block {

	padding-bottom: 10px;

}

.cpg_thumbnail {

	border: 0;
	text-align: center;
	height: <?php 
    echo $serendipity['thumbSize'];
    ?>
px;
	width: <?php 
    echo $serendipity['thumbSize'];
    ?>
px;
	background-color: #D6EFD1;
	vertical-align: middle;


}

.cpg_data {

	border: 0;
	text-align: center;
	width: <?php 
    echo $serendipity['thumbSize'];
    ?>
px;
	text-align: left;
	font-size: 9px;
	color: #669966;


}

.cpg_option {
	text-align: right;
	font-size: 10px;
	font-weight: bold;
	color: #FFFFFF;
}


.cpg_title {
	font-size: 14px;
	font-weight: bold;
	padding: 5px;
	color: #669966;
	background-color: #D6EFD1;
}


.cpg_table {

	background-color: #669966;
	margin: 0;
}


.cpg_body {

	margin: 0;
	background-color: #FFFFFF;

}

-->
</style>

<form style="display: inline; margin: 0px; padding: 0px;" method="post" action="<?php 
    echo $link;
    ?>
">
<?php 
    foreach ($CPG['get'] as $g_key => $g_val) {
        if (!is_array($g_val) && $g_key != 'page') {
            echo '<input type="hidden" name="CPG_POST[' . $g_key . ']" value="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($g_val) : htmlspecialchars($g_val, ENT_COMPAT, LANG_CHARSET)) . '" />';
        }
    }
    ?>
    <table class="cpg_table" cellspacing="0" width="100%" border="0">
        <tr>
            <td colspan="9"><div class="cpg_title"><?php 
    echo PLUGIN_CPG_TITLE;
    ?>
</div></td>
        </tr>
        <tr>
            <td><div class="cpg_option">Album</div></td>
            <td><select name="CPG_POST[album]">
                    <option value="-1">All Albums</option>

<?php 
    foreach ($albums as $alb) {
        echo '<option value="' . $alb['aid'] . '"';
        if ($alb['aid'] == $album) {
            echo " selected";
        }
        echo '>' . $alb['title'] . '</option>';
    }
    ?>

                </select>
            </td>
            <td><div class="cpg_option"><?php 
    echo SORT_BY;
    ?>
</div></td>
            <td><select name="CPG_POST[sortorder][order]">
<?php 
    foreach ($sort_order as $so_key => $so_val) {
        echo '<option value="' . $so_key . '" ' . (isset($CPG['sortorder']['order']) && $CPG['sortorder']['order'] == $so_key ? 'selected="selected"' : '') . '>' . $so_val . '</option>';
    }
    ?>
              </select>
</td>
            <td><div class="cpg_option"><?php 
    echo SORT_ORDER;
    ?>
</div></td>
            <td><select name="CPG_POST[sortorder][ordermode]">
                    <option value="DESC" <?php 
    echo isset($CPG['sortorder']['ordermode']) && $CPG['sortorder']['ordermode'] == 'DESC' ? 'selected="selected"' : '';
    ?>
><?php 
    echo SORT_ORDER_DESC;
    ?>
</option>
                    <option value="ASC"  <?php 
    echo isset($CPG['sortorder']['ordermode']) && $CPG['sortorder']['ordermode'] == 'ASC' ? 'selected="selected"' : '';
    ?>
><?php 
    echo SORT_ORDER_ASC;
    ?>
</option>
                </select>
            </td>
		<td><div class="cpg_option"><?php 
    echo FILES_PER_PAGE;
    ?>
</div></td>
		<td><select name="CPG_POST[sortorder][perpage]">
<?php 
    foreach ($sort_row_interval as $so_val) {
        echo '<option value="' . $so_val . '" ' . ($perPage == $so_val ? 'selected="selected"' : '') . '>' . $so_val . '</option>';
    }
    ?>
              </select>
		</td>
            <td align="right">
                <input type="submit" name="go" value=" - <?php 
    echo GO;
    ?>
 - " />
            </td>
        </tr>
</table>
</form>
<table border="0" width="100%">
    <tr>
        <td colspan="<?php 
    echo floor($lineBreak);
    ?>
">
            <table width="100%">
                <tr>
                    <td><?php 
    echo $left;
    ?>
</td>
                    <td align="right"><?php 
    echo $right;
    ?>
</td>
                </tr>
            </table>
        </td>
    </tr>



    <tr>

<?php 
    $x = 0;
    foreach ($images as $image) {
        ++$x;
        ?>
                <td nowrap="nowrap" align="center" valign="bottom" <?php 
        echo $manage ? 'style="border-bottom: 1px solid #000000"' : '';
        ?>
>
				<div class="cpg_thumbnail_block">
<?php 
        if (isset($url)) {
            echo '<a href="' . $url . '&amp;image=' . $image['id'] . '">';
        }
        echo '<div class="cpg_thumbnail">' . $image['thumbnail'] . '</div>';
        if (isset($url)) {
            echo '</a>';
        }
        echo '<div class="cpg_data">' . truncate($image['file'], 16) . '</div>';
        echo '<div class="cpg_data">' . $image['owner'] . '</div>';
        echo '<div class="cpg_data">' . date('d/m/y', $image['date']) . '</div>';
        ?>
				</div>
                </td>

<?php 
        // Newline?
        if ($x % $lineBreak == 0) {
            ?>
    </tr>
    <tr>
<?php 
        }
    }
    ?>
    </tr>

    <tr>
        <td colspan="<?php 
    echo floor($lineBreak);
    ?>
">
            <table width="100%">
                <tr>
                    <td><?php 
    echo $left;
    ?>
</td>
                    <td align="right"><?php 
    echo $right;
    ?>
</td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<?php 
}