Source of file SystemtaskFlushpiccache.php

Size: 2,483 Bytes - Last Modified: 2016-05-18T03:08:27+02:00

buildproject/core/module_system/admin/systemtasks/SystemtaskFlushpiccache.php

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
<?php
/*"******************************************************************************************************
*   (c) 2004-2006 by MulchProductions, www.mulchprod.de                                                 *
*   (c) 2007-2016 by Kajona, www.kajona.de                                                              *
*       Published under the GNU LGPL v2.1, see /system/licence_lgpl.txt                                 *
*-------------------------------------------------------------------------------------------------------*
*   $Id$                          *
********************************************************************************************************/

namespace Kajona\System\Admin\Systemtasks;

use Kajona\System\System\Filesystem;
use Kajona\System\System\SystemModule;


/**
 * Flushes all images saved to the cache
 *
 * @package module_system
 */
class SystemtaskFlushpiccache extends SystemtaskBase implements AdminSystemtaskInterface
{


    /**
     * @inheritdoc
     */
    public function getGroupIdentifier()
    {
        return "cache";
    }

    /**
     * @inheritdoc
     */
    public function getStrInternalTaskName()
    {
        return "flushpiccache";
    }

    /**
     * @inheritdoc
     */
    public function getStrTaskName()
    {
        return $this->getLang("systemtask_flushpiccache_name");
    }

    /**
     * @inheritdoc
     */
    public function executeTask()
    {

        if (!SystemModule::getModuleByName("system")->rightRight2()) {
            return $this->getLang("commons_error_permissions");
        }

        $strReturn = "";
        //fetch the number of images to be deleted
        $objFilesystem = new Filesystem();
        $arrFiles = $objFilesystem->getFilelist(_images_cachepath_, array());
        $intFilesDeleted = 0;
        $intTotalFiles = count($arrFiles);
        foreach ($arrFiles as $strOneFile) {
            if ($objFilesystem->fileDelete(_images_cachepath_."/".$strOneFile)) {
                $intFilesDeleted++;
            }
        }

        //build the return string
        $strReturn .= $this->getLang("systemtask_flushpiccache_done");
        $strReturn .= $this->getLang("systemtask_flushpiccache_deleted").$intFilesDeleted;
        $strReturn .= $this->getLang("systemtask_flushpiccache_skipped").($intTotalFiles - $intFilesDeleted);
        return $strReturn;
    }

    /**
     * @inheritdoc
     */
    public function getAdminForm()
    {
        return "";
    }

}