当前位置: 首页>>代码示例>>PHP>>正文


PHP Images::clear方法代码示例

本文整理汇总了PHP中Images::clear方法的典型用法代码示例。如果您正苦于以下问题:PHP Images::clear方法的具体用法?PHP Images::clear怎么用?PHP Images::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Images的用法示例。


在下文中一共展示了Images::clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: elseif

        // the action
        if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'set_as_icon') {
            $action = 'image:set_as_icon';
        } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'set_as_avatar') {
            $action = 'image:set_as_avatar';
        } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'set_as_thumbnail') {
            $action = 'image:set_as_thumbnail';
        } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'set_as_both') {
            $action = 'image:set_as_both';
        } else {
            $action = 'image:update';
        }
        // touch the related anchor
        $anchor->touch($action, $_REQUEST['id'], isset($_REQUEST['silent']) && $_REQUEST['silent'] == 'Y');
        // clear cache
        Images::clear($_REQUEST);
        // forward to the view page
        Safe::redirect($context['url_to_home'] . $context['url_to_root'] . Images::get_url($_REQUEST['id']));
    }
    // display the form on GET
} else {
    $with_form = TRUE;
}
// display the form
if ($with_form) {
    // the form to edit an image
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form" enctype="multipart/form-data"><div>';
    $fields = array();
    // the section
    if ($anchor) {
        $context['text'] .= '<input type="hidden" name="anchor" value="' . $anchor->get_reference() . '" />';
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:edit.php

示例2: post

 /**
  * post a new image or an updated image
  *
  * Accept following situations:
  * - id+image: update an existing entry in the database
  * - id+no image: only update the database
  * - no id+image: create a new entry in the database
  * - no id+no image: create a new entry in the database
  *
  * This function populates the error context, where applicable.
  *
  * @param array an array of fields
  * @return the id of the image, or FALSE on error
  **/
 public static function post(&$fields)
 {
     global $context;
     // no anchor reference
     if (!isset($fields['anchor']) || !$fields['anchor']) {
         Logger::error(i18n::s('No anchor has been found.'));
         return FALSE;
     }
     // get the anchor
     if (!($anchor = Anchors::get($fields['anchor']))) {
         Logger::error(i18n::s('No anchor has been found.'));
         return FALSE;
     }
     // set default values
     if (!isset($fields['use_thumbnail']) || !Surfer::get_id()) {
         $fields['use_thumbnail'] = 'Y';
     }
     // only authenticated users can select to not moderate image sizes
     // set default values for this editor
     Surfer::check_default_editor($fields);
     // update the existing record
     if (isset($fields['id'])) {
         // id cannot be empty
         if (!isset($fields['id']) || !is_numeric($fields['id'])) {
             Logger::error(i18n::s('No item has the provided id.'));
             return FALSE;
         }
         $query = "UPDATE " . SQL::table_name('images') . " SET ";
         if (isset($fields['image_name']) && $fields['image_name'] != 'none') {
             $query .= "image_name='" . SQL::escape($fields['image_name']) . "'," . "thumbnail_name='" . SQL::escape($fields['thumbnail_name']) . "'," . "image_size='" . SQL::escape($fields['image_size']) . "'," . "edit_name='" . SQL::escape($fields['edit_name']) . "'," . "edit_id=" . SQL::escape($fields['edit_id']) . "," . "edit_address='" . SQL::escape($fields['edit_address']) . "'," . "edit_date='" . SQL::escape($fields['edit_date']) . "',";
         }
         $query .= "title='" . SQL::escape(isset($fields['title']) ? $fields['title'] : '') . "'," . "use_thumbnail='" . SQL::escape($fields['use_thumbnail']) . "'," . "description='" . SQL::escape(isset($fields['description']) ? $fields['description'] : '') . "'," . "source='" . SQL::escape(isset($fields['source']) ? $fields['source'] : '') . "'," . "link_url='" . SQL::escape(isset($fields['link_url']) ? $fields['link_url'] : '') . "'" . " WHERE id = " . SQL::escape($fields['id']);
         // actual update
         if (SQL::query($query) === FALSE) {
             return FALSE;
         }
         // insert a new record
     } elseif (isset($fields['image_name']) && $fields['image_name'] && isset($fields['image_size']) && $fields['image_size']) {
         $query = "INSERT INTO " . SQL::table_name('images') . " SET ";
         $query .= "anchor='" . SQL::escape($fields['anchor']) . "'," . "image_name='" . SQL::escape($fields['image_name']) . "'," . "image_size='" . SQL::escape($fields['image_size']) . "'," . "title='" . SQL::escape(isset($fields['title']) ? $fields['title'] : '') . "'," . "use_thumbnail='" . SQL::escape($fields['use_thumbnail']) . "'," . "description='" . SQL::escape(isset($fields['description']) ? $fields['description'] : '') . "'," . "source='" . SQL::escape(isset($fields['source']) ? $fields['source'] : '') . "'," . "thumbnail_name='" . SQL::escape(isset($fields['thumbnail_name']) ? $fields['thumbnail_name'] : '') . "'," . "link_url='" . SQL::escape(isset($fields['link_url']) ? $fields['link_url'] : '') . "'," . "edit_name='" . SQL::escape($fields['edit_name']) . "'," . "edit_id=" . SQL::escape($fields['edit_id']) . "," . "edit_address='" . SQL::escape($fields['edit_address']) . "'," . "edit_date='" . SQL::escape($fields['edit_date']) . "'";
         // actual update
         if (SQL::query($query) === FALSE) {
             return FALSE;
         }
         // remember the id of the new item
         $fields['id'] = SQL::get_last_id($context['connection']);
         // nothing done
     } else {
         Logger::error(i18n::s('No image has been added.'));
         return FALSE;
     }
     // clear the cache
     Images::clear($fields);
     // end of job
     return $fields['id'];
 }
开发者ID:rair,项目名称:yacs,代码行数:70,代码来源:images.php

示例3: elseif

// not found
if (!isset($item['id'])) {
    include '../error.php';
    // permission denied
} elseif (!$permitted) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // deletion is confirmed
} elseif (isset($_REQUEST['confirm']) && $_REQUEST['confirm'] == 'yes') {
    // touch the related anchor before actual deletion, since the image has to be accessible at that time
    if (is_object($anchor)) {
        $anchor->touch('image:delete', $item['id']);
    }
    // if no error, back to the anchor or to the index page
    if (Images::delete($item['id'])) {
        Images::clear($item);
        if (isset($_REQUEST['strait'])) {
            $output['success'] = true;
            // provide a new field if required
            if (isset($_REQUEST['newfield'])) {
                $indice = $_REQUEST['newfield'] ? $_REQUEST['newfield'] : '';
                $output['replace'] = Skin::build_input_file('upload' . $indice);
            }
        } elseif (isset($_REQUEST['follow_up'])) {
            Safe::redirect($_REQUEST['follow_up']);
        } elseif (is_object($anchor)) {
            Safe::redirect($anchor->get_url());
        } else {
            Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'images/');
        }
    }
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:delete.php


注:本文中的Images::clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。