+ Antworten
Ergebnis 1 bis 3 von 3

Thema: Eventlist 0.8x Housekeeping integrieren

  1. #1
    Neu an Board
    Registriert seit
    30.05.2006
    Beiträge
    63
    Bedankte sich
    3
    1 Danksagung in 1 Beitrag

    Standard Eventlist 0.8x Housekeeping integrieren

    Hallo, ich hoffe ich bin hier im richtigen Forumteil.

    Ich benutze auf einer größeren Seite noch Joomla 1.x, deswegen läuft auch die Eventlist nur in der Version 0.8x und nicht die neue 0.9 Version, in dieser Version wäre die Funktion "Housekeeping" integriert die Flyer löscht, die nicht mehr benötigt werden, also von Events die schon vorbei sind, werden die Flyer aufm FTP gelöscht.

    Und genau das bräuchte ich für die alte 0.8 Version.

    Ich hab von schlu.net schon den betreffenen Code bekommen, aber ich kann dann nicht so umsetzen das der auch in der alten Eventlist läuft.

    Könntet ihr mir helfen?

    Hier der Housekeeping Code:
    PHP-Code:
    <?php
        2 
    /**
        3  * @version 0.9 $Id$
        4  * @package Joomla
        5  * @subpackage EventList
        6  * @copyright (C) 2005 - 2008 Christoph Lukes
        7  * @license GNU/GPL, see LICENSE.php
        8  * EventList is free software; you can redistribute it and/or
        9  * modify it under the terms of the GNU General Public License 2
       10  * as published by the Free Software Foundation.
       11 
       12  * EventList is distributed in the hope that it will be useful,
       13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       15  * GNU General Public License for more details.
       16 
       17  * You should have received a copy of the GNU General Public License
       18  * along with EventList; if not, write to the Free Software
       19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
       20  */
       
    21 
       22 
    // no direct access
       
    23 defined('_JEXEC') or die('Restricted access');
       
    24 
       25 jimport
    ('joomla.application.component.model');
       
    26 jimport('joomla.filesystem.folder');
       
    27 jimport('joomla.filesystem.file');
       
    28 
       29 
    /**
       30  * EventList Component Cleanup Model
       31  *
       32  * @package Joomla
       33  * @subpackage EventList
       34  * @since        0.9
       35  */
       
    36 class EventListModelCleanup extends JModel
       37 
    {
       
    38     /**
       39      * target
       40      *
       41      * @var string
       42      */
       
    43     var $_target null;
       
    44 
       45     
    /**
       46      * images to delete
       47      *
       48      * @var array
       49      */
       
    50     var $_images null;
       
    51 
       52     
    /**
       53      * assigned images
       54      *
       55      * @var array
       56      */
       
    57     var $_assigned null;
       
    58 
       59     
    /**
       60      * unassigned images
       61      *
       62      * @var array
       63      */
       
    64     var $_unassigned null;
       
    65 
       66     
    /**
       67      * Constructor
       68      *
       69      * @since 0.9
       70      */
       
    71     function __construct()
       
    72     {
       
    73         parent::__construct();
       
    74 
       75         
    if (JRequest::getCmd('task') == 'cleaneventimg') {
       
    76             $target 'events';
       
    77         } else {
       
    78             $target 'venues';
       
    79         }
       
    80         $this->settarget($target);
       
    81     }
       
    82 
       83     
    /**
       84      * Method to set the target
       85      *
       86      * @access    public
       87      * @param    string the target directory
       88      */
       
    89     function settarget($target)
       
    90     {
       
    91         // Set id and wipe data
       
    92         $this->_target     $target;
       
    93     }
       
    94 
       95     
    /**
       96      * Method to delete the images
       97      *
       98      * @access    public
       99      * @since 0.9
      100      * @return int
      101      */
      
    102     function delete()
      
    103     {
      
    104         // Set FTP credentials, if given
      
    105         jimport('joomla.client.helper');
      
    106         JClientHelper::setCredentialsFromRequest('ftp');
      
    107 
      108         
    // Get some data from the request
      
    109         $images    $this->_getImages();
      
    110         $folder $this->_target;
      
    111 
      112         $count 
    count($images);
      
    113 
      114         
    if ($count) {
      
    115 
      116             $fail 
    0;
      
    117 
      118             
    foreach ($images as $image)
      
    119             {
      
    120                 if ($image !== JFilterInput::clean($image'path')) {
      
    121                     JError::raiseWarning(100JText::_('UNABLE TO DELETE').' '.htmlspecialchars($imageENT_COMPAT'UTF-8'));
      
    122                     $fail++;
      
    123                     continue;
      
    124                 }
      
    125 
      126                 $fullPath 
    JPath::clean(JPATH_SITE.DS.'images'.DS.'eventlist'.DS.$folder.DS.$image);
      
    127                 $fullPaththumb JPath::clean(JPATH_SITE.DS.'images'.DS.'eventlist'.DS.$folder.DS.'small'.DS.$image);
      
    128 
      129                 
    if (is_file($fullPath)) {
      
    130                     JFile::delete($fullPath);
      
    131                     if (JFile::exists($fullPaththumb)) {
      
    132                         JFile::delete($fullPaththumb);
      
    133                     }
      
    134                 }
      
    135             }
      
    136         }
      
    137 
      138         $deleted 
    $count $fail;
      
    139 
      140         
    return $deleted;
      
    141     }
      
    142 
      143     
    /**
      144      * Method to determine the images to delete
      145      *
      146      * @access    private
      147      * @since 0.9
      148      * @return array
      149      */
      
    150     function _getImages()
      
    151     {
      
    152         $this->_images array_diff($this->_getavailable(), $this->_getassigned());
      
    153 
      154         
    return $this->_images;
      
    155     }
      
    156 
      157     
    /**
      158      * Method to determine the assigned images
      159      *
      160      * @access    private
      161      * @since 0.9
      162      * @return array
      163      */
      
    164     function _getassigned()
      
    165     {
      
    166         if ($this->_target == 'events') {
      
    167             $field 'datimage';
      
    168         } else {
      
    169             $field 'locimage';
      
    170         }
      
    171 
      172         $query 
    'SELECT '.$field.' FROM #__eventlist_'.$this->_target;
      
    173 
      174         $this
    ->_db->setQuery($query);
      
    175 
      176         $this
    ->_assigned $this->_db->loadResultArray();
      
    177 
      178         
    return $this->_assigned;
      
    179     }
      
    180 
      181     
    /**
      182      * Method to determine the unassigned images
      183      *
      184      * @access    private
      185      * @since 0.9
      186      * @return array
      187      */
      
    188     function _getavailable()
      
    189     {
      
    190         // Initialize variables
      
    191         $basePath JPATH_SITE.DS.'images'.DS.'eventlist'.DS.$this->_target;
      
    192 
      193         $images     
    = array ();
      
    194 
      195         
    // Get the list of files and folders from the given folder
      
    196         $fileList     JFolder::files($basePath);
      
    197 
      198         
    // Iterate over the files if they exist
      
    199         if ($fileList !== false) {
      
    200             foreach ($fileList as $file)
      
    201             {
      
    202                 if (is_file($basePath.DS.$file) && substr($file01) != '.' && strtolower($file) !== 'index.html') {
      
    203 
      204                     $images
    [] = $file;
      
    205 
      206                 
    }
      
    207             }
      
    208         }
      
    209 
      210         $this
    ->_unassigned $images;
      
    211 
      212         
    return $this->_unassigned;
      
    213     }
      
    214 }
      
    215 ?>
    Und hier der Code in der alten Version, der nur die Datenbankeinträge löscht:

    PHP-Code:
        function cleanup()
        {
              global 
    $database;

              require(
    ELPATH.'/../../administrator/components/com_eventlist/config.eventlist.php');

              
    $nulldate '0000-00-00';

              
    //Datens�tze l�schen die �lter als $minus Tage sind
            
    if ($oldevent == 1) {

                
    $query 'DELETE FROM #__eventlist_dates WHERE DATE_SUB(NOW(), INTERVAL '.(int)$minus.' DAY) > (IF (enddates <> '.$nulldate.', enddates, dates))';

                
    $database->SetQuery($query);
                
    $database->Query();
            }

            
    //Datens�tze in das Archiv verschieben die �lter als $minus Tage sind
            
    if ($oldevent == 2) {

                
    $query 'UPDATE #__eventlist_dates SET published = -1 WHERE DATE_SUB(NOW(), INTERVAL '.(int)$minus.' DAY) > (IF (enddates <> '.$nulldate.', enddates, dates))';

                
    $database->SetQuery$query );
                
    $database->Query();
            }
        } 
    Bitte um Hilfe... ich kann nicht jeden Tag die betreffenen Flyer von Hand aufm Server löschen bei so vielen.

    Danke für die Hilfe!

    Gruß

  2. Erhielt Danksagungen von:


  3. #2
    Neu an Board
    Registriert seit
    30.05.2006
    Beiträge
    63
    Bedankte sich
    3
    1 Danksagung in 1 Beitrag

    Standard

    Weiß keiner Rat? Ich kann ja schlecht aufm Server parallel Joomla 1.5 installieren mit Eventlist 0.9 nur das ich dieses Feature habe....

  4. #3
    Neu an Board
    Registriert seit
    16.09.2009
    Beiträge
    1
    Bedankte sich
    1
    Erhielt 0 Danksagungen
    in 0 Beiträgen

    Standard house cleaning service

    The best inhouse house keeping with the most professional and trained people personalized as per your own requirements.
    ================================================== ===============
    ACRUZ
    house cleaning service
    Zitat Zitat von Mikelop Beitrag anzeigen
    Hallo, ich hoffe ich bin hier im richtigen Forumteil.

    Ich benutze auf einer größeren Seite noch Joomla 1.x, deswegen läuft auch die Eventlist nur in der Version 0.8x und nicht die neue 0.9 Version, in dieser Version wäre die Funktion "Housekeeping" integriert die Flyer löscht, die nicht mehr benötigt werden, also von Events die schon vorbei sind, werden die Flyer aufm FTP gelöscht.

    Und genau das bräuchte ich für die alte 0.8 Version.

    Ich hab von schlu.net schon den betreffenen Code bekommen, aber ich kann dann nicht so umsetzen das der auch in der alten Eventlist läuft.

    Könntet ihr mir helfen?

    Hier der Housekeeping Code:
    PHP-Code:
    <?php
        2 
    /**
        3  * @version 0.9 $Id$
        4  * @package Joomla
        5  * @subpackage EventList
        6  * @copyright (C) 2005 - 2008 Christoph Lukes
        7  * @license GNU/GPL, see LICENSE.php
        8  * EventList is free software; you can redistribute it and/or
        9  * modify it under the terms of the GNU General Public License 2
       10  * as published by the Free Software Foundation.
       11 
       12  * EventList is distributed in the hope that it will be useful,
       13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       15  * GNU General Public License for more details.
       16 
       17  * You should have received a copy of the GNU General Public License
       18  * along with EventList; if not, write to the Free Software
       19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
       20  */
       
    21 
       22 
    // no direct access
       
    23 defined('_JEXEC') or die('Restricted access');
       
    24 
       25 jimport
    ('joomla.application.component.model');
       
    26 jimport('joomla.filesystem.folder');
       
    27 jimport('joomla.filesystem.file');
       
    28 
       29 
    /**
       30  * EventList Component Cleanup Model
       31  *
       32  * @package Joomla
       33  * @subpackage EventList
       34  * @since        0.9
       35  */
       
    36 class EventListModelCleanup extends JModel
       37 
    {
       
    38     /**
       39      * target
       40      *
       41      * @var string
       42      */
       
    43     var $_target null;
       
    44 
       45     
    /**
       46      * images to delete
       47      *
       48      * @var array
       49      */
       
    50     var $_images null;
       
    51 
       52     
    /**
       53      * assigned images
       54      *
       55      * @var array
       56      */
       
    57     var $_assigned null;
       
    58 
       59     
    /**
       60      * unassigned images
       61      *
       62      * @var array
       63      */
       
    64     var $_unassigned null;
       
    65 
       66     
    /**
       67      * Constructor
       68      *
       69      * @since 0.9
       70      */
       
    71     function __construct()
       
    72     {
       
    73         parent::__construct();
       
    74 
       75         
    if (JRequest::getCmd('task') == 'cleaneventimg') {
       
    76             $target 'events';
       
    77         } else {
       
    78             $target 'venues';
       
    79         }
       
    80         $this->settarget($target);
       
    81     }
       
    82 
       83     
    /**
       84      * Method to set the target
       85      *
       86      * @access    public
       87      * @param    string the target directory
       88      */
       
    89     function settarget($target)
       
    90     {
       
    91         // Set id and wipe data
       
    92         $this->_target     $target;
       
    93     }
       
    94 
       95     
    /**
       96      * Method to delete the images
       97      *
       98      * @access    public
       99      * @since 0.9
      100      * @return int
      101      */
      
    102     function delete()
      
    103     {
      
    104         // Set FTP credentials, if given
      
    105         jimport('joomla.client.helper');
      
    106         JClientHelper::setCredentialsFromRequest('ftp');
      
    107 
      108         
    // Get some data from the request
      
    109         $images    $this->_getImages();
      
    110         $folder $this->_target;
      
    111 
      112         $count 
    count($images);
      
    113 
      114         
    if ($count) {
      
    115 
      116             $fail 
    0;
      
    117 
      118             
    foreach ($images as $image)
      
    119             {
      
    120                 if ($image !== JFilterInput::clean($image'path')) {
      
    121                     JError::raiseWarning(100JText::_('UNABLE TO DELETE').' '.htmlspecialchars($imageENT_COMPAT'UTF-8'));
      
    122                     $fail++;
      
    123                     continue;
      
    124                 }
      
    125 
      126                 $fullPath 
    JPath::clean(JPATH_SITE.DS.'images'.DS.'eventlist'.DS.$folder.DS.$image);
      
    127                 $fullPaththumb JPath::clean(JPATH_SITE.DS.'images'.DS.'eventlist'.DS.$folder.DS.'small'.DS.$image);
      
    128 
      129                 
    if (is_file($fullPath)) {
      
    130                     JFile::delete($fullPath);
      
    131                     if (JFile::exists($fullPaththumb)) {
      
    132                         JFile::delete($fullPaththumb);
      
    133                     }
      
    134                 }
      
    135             }
      
    136         }
      
    137 
      138         $deleted 
    $count $fail;
      
    139 
      140         
    return $deleted;
      
    141     }
      
    142 
      143     
    /**
      144      * Method to determine the images to delete
      145      *
      146      * @access    private
      147      * @since 0.9
      148      * @return array
      149      */
      
    150     function _getImages()
      
    151     {
      
    152         $this->_images array_diff($this->_getavailable(), $this->_getassigned());
      
    153 
      154         
    return $this->_images;
      
    155     }
      
    156 
      157     
    /**
      158      * Method to determine the assigned images
      159      *
      160      * @access    private
      161      * @since 0.9
      162      * @return array
      163      */
      
    164     function _getassigned()
      
    165     {
      
    166         if ($this->_target == 'events') {
      
    167             $field 'datimage';
      
    168         } else {
      
    169             $field 'locimage';
      
    170         }
      
    171 
      172         $query 
    'SELECT '.$field.' FROM #__eventlist_'.$this->_target;
      
    173 
      174         $this
    ->_db->setQuery($query);
      
    175 
      176         $this
    ->_assigned $this->_db->loadResultArray();
      
    177 
      178         
    return $this->_assigned;
      
    179     }
      
    180 
      181     
    /**
      182      * Method to determine the unassigned images
      183      *
      184      * @access    private
      185      * @since 0.9
      186      * @return array
      187      */
      
    188     function _getavailable()
      
    189     {
      
    190         // Initialize variables
      
    191         $basePath JPATH_SITE.DS.'images'.DS.'eventlist'.DS.$this->_target;
      
    192 
      193         $images     
    = array ();
      
    194 
      195         
    // Get the list of files and folders from the given folder
      
    196         $fileList     JFolder::files($basePath);
      
    197 
      198         
    // Iterate over the files if they exist
      
    199         if ($fileList !== false) {
      
    200             foreach ($fileList as $file)
      
    201             {
      
    202                 if (is_file($basePath.DS.$file) && substr($file01) != '.' && strtolower($file) !== 'index.html') {
      
    203 
      204                     $images
    [] = $file;
      
    205 
      206                 
    }
      
    207             }
      
    208         }
      
    209 
      210         $this
    ->_unassigned $images;
      
    211 
      212         
    return $this->_unassigned;
      
    213     }
      
    214 }
      
    215 ?>
    Und hier der Code in der alten Version, der nur die Datenbankeinträge löscht:

    PHP-Code:
        function cleanup()
        {
              global 
    $database;

              require(
    ELPATH.'/../../administrator/components/com_eventlist/config.eventlist.php');

              
    $nulldate '0000-00-00';

              
    //Datens�tze l�schen die �lter als $minus Tage sind
            
    if ($oldevent == 1) {

                
    $query 'DELETE FROM #__eventlist_dates WHERE DATE_SUB(NOW(), INTERVAL '.(int)$minus.' DAY) > (IF (enddates <> '.$nulldate.', enddates, dates))';

                
    $database->SetQuery($query);
                
    $database->Query();
            }

            
    //Datens�tze in das Archiv verschieben die �lter als $minus Tage sind
            
    if ($oldevent == 2) {

                
    $query 'UPDATE #__eventlist_dates SET published = -1 WHERE DATE_SUB(NOW(), INTERVAL '.(int)$minus.' DAY) > (IF (enddates <> '.$nulldate.', enddates, dates))';

                
    $database->SetQuery$query );
                
    $database->Query();
            }
        } 
    Bitte um Hilfe... ich kann nicht jeden Tag die betreffenen Flyer von Hand aufm Server löschen bei so vielen.

    Danke für die Hilfe!

    Gruß

+ Antworten

Lesezeichen

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein