Changeset 320


Ignore:
Timestamp:
Mar 21, 2008 10:20:11 AM (16 years ago)
Author:
quinn
Message:

Added a glob function to the ImageThumb? deleteThumbs method. Fixed some HTML errors. Minor admin2 CSS tweaks.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/module_maker/list_template.cli.php

    r316 r320  
    182182
    183183echo isset($op) ? '' : <<<E_O_F
    184         <td class="sc-nowrap" align="right"><a title="<\x3fphp printf(_("Delete %s"), oTxt(\$list[\$i]['__///__'])) \x3f>" href="<\x3fphp echo \$app->oHREF(\$_SERVER['PHP_SELF'] . "?op=del&$primary_key=" . \$list[\$i]['$primary_key']); \x3f>" onclick"javascript:return confirm('<\x3fphp printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt(\$list[\$i]['__///__'])) \x3f>');"><img src="/admin/i/trash.gif" alt="Delete" width="10" height="10" border="0" /></a> &nbsp;</td>
     184        <td class="sc-nowrap" align="right"><a title="<\x3fphp printf(_("Delete %s"), oTxt(\$list[\$i]['__///__'])) \x3f>" href="<\x3fphp echo \$app->oHREF(\$_SERVER['PHP_SELF'] . "?op=del&$primary_key=" . \$list[\$i]['$primary_key']); \x3f>" onclick="javascript:return confirm('<\x3fphp printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt(\$list[\$i]['__///__'])) \x3f>');"><img src="/admin/i/trash.gif" alt="Delete" width="10" height="10" border="0" /></a> &nbsp;</td>
    185185    </tr>
    186186    <\x3fphp } \x3f>
  • trunk/bin/module_maker/skel/adm_list.ihtml

    r316 r320  
    2929        <td class="sc-padleft sc-nowrap"><a title="<?php printf(_("Versions of %s"), oTxt($list[$i]['__///__'])) ?>" href="<?php echo $app->oHREF('/admin/versions.php?record_table=%DB_TBL%&record_key=%PRIMARY_KEY%&boomerang=true&record_val=' . $list[$i]['%PRIMARY_KEY%']); ?>"><img src="/admin/i/multiple.png" alt="" width="12" height="12" border="0" /></a> &nbsp;</td>
    3030%ADM_LIST_ROWS%
    31         <td class="sc-padleft sc-nowrap" align="right"><a title="<?php printf(_("Delete %s"), oTxt($list[$i]['__///__'])) ?>" href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . "?op=del&%PRIMARY_KEY%=" . $list[$i]['%PRIMARY_KEY%']); ?>" onclick"javascript:return confirm('<?php printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt($list[$i]['__///__'])) ?>');"><img src="/admin/i/trash.gif" alt="Delete" width="10" height="10" border="0" /></a> &nbsp;</td>
     31        <td class="sc-padleft sc-nowrap" align="right"><a title="<?php printf(_("Delete %s"), oTxt($list[$i]['__///__'])) ?>" href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . "?op=del&%PRIMARY_KEY%=" . $list[$i]['%PRIMARY_KEY%']); ?>" onclick="javascript:return confirm('<?php printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt($list[$i]['__///__'])) ?>');"><img src="/admin/i/trash.gif" alt="Delete" width="10" height="10" border="0" /></a> &nbsp;</td>
    3232    </tr>
    3333    <?php } ?>
  • trunk/css/admin2.inc.css

    r297 r320  
    126126
    127127#leftnav a.addlink {
    128     margin-left: 0.5em;
     128    margin-left: 0.25em;
    129129    font-weight: normal;
    130130}
     
    288288
    289289.sc-form-row {
    290     margin: .35em 0;
     290    margin: .5em 0;
    291291}
    292292.sc-form-row:after { content: " "; display: block; visibility: hidden; clear: both; height: 0.1px; font-size: 0.1em; line-height: 0; } /* clear floats - Ydnar Hack */
     
    329329.sc-form-row label {
    330330    font-size: 70%;
    331     padding-top: 0.5em;
     331    padding-top: 0.25em;
    332332}
    333333
     
    352352input[type="button"] {
    353353    margin-right: 5px;
     354    padding: 0.4em 0.6em;
    354355    border: 1px solid #ccc;
     356    background-color: #eee;
    355357}
    356358
    357359.sc-submit-buttons {
    358     margin-top: 20px;
     360    margin: 20px 0 20px 130px;
    359361}
    360362.sc-form-row .sc-help {
  • trunk/lib/ImageThumb.inc.php

    r315 r320  
    638638     *
    639639     * @access  public
    640      * @param   string $file_name The file name to delete, with extension.
     640     * @param   string  $file_name  The file name to delete, with extension.
     641     * @param   bool    $use_glob   Set true to use glob to find the filename (using $file_name as a pattern)
    641642     * @return  bool true on success, false on failure.
    642643     */
    643     function deleteThumbs($file_name)
     644    function deleteThumbs($file_name, $use_glob=false)
    644645    {
    645646        $app =& App::getInstance();
     
    653654        $return_val = 0;
    654655        foreach ($this->_image_specs as $spec) {
    655             if ('/' == $spec['dest_dir']{0}) {
    656                 // Absolute path.
    657                 $dest_file = realpath(sprintf('%s/%s.%s', $spec['dest_dir'], mb_substr($file_name, 0, mb_strrpos($file_name, '.')), $spec['dest_file_extension']));               
     656            // Get base directory depending on if the spec's dest_dir is an absolute path or not.
     657            $dest_dir = '/' == $spec['dest_dir']{0} ? $spec['dest_dir'] : sprintf('%s/%s', $this->getParam('source_dir'), $spec['dest_dir']);
     658            if ($use_glob) {
     659                $dest_file = realpath(sprintf('%s/%s', $dest_dir, $this->_glob($file_name, $dest_dir)));               
    658660            } else {
    659                 // Relative path.
    660                 $dest_file = realpath(sprintf('%s/%s/%s.%s', $this->getParam('source_dir'), $spec['dest_dir'], mb_substr($file_name, 0, mb_strrpos($file_name, '.')), $spec['dest_file_extension']));
    661             }
     661                $dest_file = realpath(sprintf('%s/%s.%s', $dest_dir, mb_substr($file_name, 0, mb_strrpos($file_name, '.')), $spec['dest_file_extension']));
     662            }           
     663           
    662664            if (file_exists($dest_file)) {
    663665                if (!unlink($dest_file)) {
     
    667669            }
    668670        }
    669         $app->logMsg(sprintf('Thumbnails deleted for file: %s', $file_name), LOG_INFO, __FILE__, __LINE__);
     671        $app->logMsg(sprintf('Thumbnails deleted for file: %s', $dest_file), LOG_DEBUG, __FILE__, __LINE__);
    670672        return 0 === $return_val;
    671673    }
     
    766768                    $dest_dir = dirname($filename);
    767769                } else {
    768                     if ('/' == $spec['dest_dir']{0}) {
    769                         // Absolute path.
    770                         $dest_dir = $spec['dest_dir'];
    771                     } else {
    772                         // Relative path.
    773                         $dest_dir = sprintf('%s/%s', $this->getParam('source_dir'), $spec['dest_dir']);
    774                     }
     770                    // Get base directory depending on if the spec's dest_dir is an absolute path or not.
     771                    $dest_dir = '/' == $spec['dest_dir']{0} ? $spec['dest_dir'] : sprintf('%s/%s', $this->getParam('source_dir'), $spec['dest_dir']);
    775772                }
    776773                if (!file_exists($dest_dir)) {
     
    835832        }
    836833    }
     834   
     835    /**
     836     * Get filename by glob pattern. Searches a directory for an image that matches the
     837     * specified glob pattern and returns the filename of the first file found.
     838     *
     839     * @access  public
     840     * @param   string  $pattern    Pattern to match filename.
     841     * @param   string  $directory  Pattern to match containing directory.
     842     * @return  string filename on success, empty string on failure.
     843     * @author  Quinn Comendant <quinn@strangecode.com>
     844     * @since   15 Nov 2005 20:55:22
     845     */
     846    function _glob($pattern, $directory)
     847    {
     848        $file_list = glob(sprintf('%s/%s', $directory, $pattern));
     849        if (isset($file_list[0])) {
     850            return basename($file_list[0]);
     851        } else {
     852            return '';
     853        }
     854    }
    837855
    838856} // End of class.
  • trunk/lib/Utilities.inc.php

    r294 r320  
    108108/**
    109109 * Returns text with stylistic modifications. Warning: this will break some HTML attibutes!
    110  * TODO: Allow a string such as this to be passted: <a href="javascript:openPopup('/foo/bar.php')">Click here</a>
     110 * TODO: Allow a string such as this to be passed: <a href="javascript:openPopup('/foo/bar.php')">Click here</a>
    111111 *
    112112 * @param  string   $text Text to clean.
  • trunk/services/templates/admin_list.ihtml

    r316 r320  
    5050        <td class="sc-nowrap"><?php echo oTxt($list[$i]['added_admin_username'], true); ?> &nbsp;</td>
    5151        <td class="sc-nowrap"><?php echo '0000-00-00 00:00:00' == $list[$i]['modified_datetime'] ? '' : date($app->getParam('date_format'), strtotime($list[$i]['modified_datetime'])); ?> &nbsp;</td>
    52         <td class="sc-padleft sc-nowrap" align="right"><a title="<?php printf(_("Delete %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . "?op=del&admin_id=" . $list[$i]['admin_id']); ?>" onclick"javascript:return confirm('<?php printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt($list[$i]['username'])) ?>')"><img src="/admin/i/trash.gif" alt="Delete" width="10" height="10" border="0" /></a> &nbsp;</td>
     52        <td class="sc-padleft sc-nowrap" align="right"><a title="<?php printf(_("Delete %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . "?op=del&admin_id=" . $list[$i]['admin_id']); ?>" onclick="javascript:return confirm('<?php printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt($list[$i]['username'])) ?>')"><img src="/admin/i/trash.gif" alt="Delete" width="10" height="10" border="0" /></a> &nbsp;</td>
    5353    </tr>
    5454    <?php } ?>
  • trunk/services/templates/log_list.ihtml

    r296 r320  
    2121                <?php if (!preg_match($no_download_files, $l['filename'])) { ?><a class="sc-padright" href="<?php echo $app->oHREF('/admin/logs.php?op=download&log=' . $l['filename']); ?>"><?php echo _("Download"); ?></a><?php } ?>
    2222                <?php if (!preg_match($no_archive_files, $l['filename'])) { ?><a class="sc-padright" href="<?php echo $app->oHREF('/admin/logs.php?op=archive&log=' . $l['filename']); ?>"><?php echo _("Archive"); ?></a><?php } ?>
    23                 <?php if (!preg_match($no_clear_files, $l['filename'])) { ?><a class="sc-padright" href="<?php echo $app->oHREF('/admin/logs.php?op=clear&log=' . $l['filename']); ?>" onclick"javascript:return confirm('<?php printf(_("Are you sure you want to clear the log file %s? This will empty this file of its contents. This action is not reversible."), $l['filename'])?>')"><?php echo _("Clear"); ?></a><?php } ?>
    24                 <?php if (!preg_match($no_delete_files, $l['filename'])) { ?><a href="<?php echo $app->oHREF('/admin/logs.php?op=delete&log=' . $l['filename']); ?>" onclick"javascript:return confirm('<?php printf(_("Are you sure you want to delete the log file %s? This will remove this log file permanently. This action is not reversible."), $l['filename'])?>')"><?php echo _("Delete"); ?></a><?php } ?>
     23                <?php if (!preg_match($no_clear_files, $l['filename'])) { ?><a class="sc-padright" href="<?php echo $app->oHREF('/admin/logs.php?op=clear&log=' . $l['filename']); ?>" onclick="javascript:return confirm('<?php printf(_("Are you sure you want to clear the log file %s? This will empty this file of its contents. This action is not reversible."), $l['filename'])?>')"><?php echo _("Clear"); ?></a><?php } ?>
     24                <?php if (!preg_match($no_delete_files, $l['filename'])) { ?><a href="<?php echo $app->oHREF('/admin/logs.php?op=delete&log=' . $l['filename']); ?>" onclick="javascript:return confirm('<?php printf(_("Are you sure you want to delete the log file %s? This will remove this log file permanently. This action is not reversible."), $l['filename'])?>')"><?php echo _("Delete"); ?></a><?php } ?>
    2525            </td>
    2626        </tr><?php
Note: See TracChangeset for help on using the changeset viewer.