ACC SHELL

Path : /srv/www/vhosts/profias/modules/photogallery/
File Upload :
Current File : /srv/www/vhosts/profias/modules/photogallery/photogallery.php

<?php


  class Photogallery extends Module
  {
  
    function Photogallery($path)
    {
      $this->getModuleInfo($path.'/photogallery');
    }

    function install()
    {
      $db=$GLOBALS['db'];
      
      $db->createTable('photogallerys', 'module');
      $db->createColumn('photogallerys', 'preview', 'integer');
      $db->createColumn('photogallerys', 'author', 'integer');
      $db->createColumn('photogallerys', 'id_page', 'integer');
      $db->createColumn('photogallerys', 'year', 'short text');

      $db->createTable('photogallerys_files', 'module');
      $db->createColumn('photogallerys_files', 'id_photogallery', 'integer');
      $db->createColumn('photogallerys_files', 'id_file', 'integer');
    
      $db->createTable('photogallerys_languages', 'module');
      $db->createColumn('photogallerys_languages', 'id_photogallery', 'integer');
      $db->createColumn('photogallerys_languages', 'id_language', 'integer');
      $db->createColumn('photogallerys_languages', 'name', 'short text');
      $db->createColumn('photogallerys_languages', 'description', 'medium text');
      
      return TRUE;
    }
  
    function uninstall()
    {
      $db=$GLOBALS['db'];
      
      $db->dropColumn('photogallerys', 'preview');
      $db->dropColumn('photogallerys', 'author');
      $db->dropColumn('photogallerys', 'id_page');
      $db->dropColumn('photogallerys', 'year');
      $db->dropTable('photogallerys');

      $db->dropColumn('photogallerys_files', 'id_photogallery');
      $db->dropColumn('photogallerys_files', 'id_file');
      $db->dropTable('photogallerys_files');
    
      $db->dropColumn('photogallerys_languages', 'id_photogallery');
      $db->dropColumn('photogallerys_languages', 'id_language');
      $db->dropColumn('photogallerys_languages', 'name');
      $db->dropColumn('photogallerys_languages', 'description');
      $db->dropTable('photogallerys_languages');
      
      return TRUE;
    }
  
  
    function backEnd()
    {
      $result='';
    $db=$GLOBALS['db'];
    
  $actions=array(
    'add'=>'Přidat fotogalerii',
    'add_now'=>'Přidat',
    'list'=>'Seznam fotogalerií',
    'edit'=>'Upravit',
    'edit_confirm'=>'Uložit',
    'after_add'=>'Upravit',
    'after_confirm'=>'Seznam fotogalerií',
    'deactive'=>'deaktivovat',
    'active'=>'aktivovat',
    'delete'=>'Smazat fotogalerii',
    'delete_confirm'=>'Ano, smazat'
  );
 
 

  $id_module=$db->select(
    'id',
    'sys_modules',
    'sys_name = "photogallery"',
    '1'
  );


    if (FALSE == isset($_GET["c"])){
      $type = array(
        'type'=>'reference',
        'name'=>'Galerie pro stránku',
        'field'=>'id_page',
        'reg'=>'^.+$',
        'join'=>' LEFT JOIN sys_pages as sp on (sp.id = sys_pages_languages.id_page)',
        'where'=>' and id_language=1 and sp.active="Y" and sp.id_module=2',
        'ftable'=>'sys_pages_languages',
        'ffield'=>'name',
        'fkey'=>'id_page',
        'default'=>'0',
      );
      $wh = '';     
  }else{
    $type = array(
      'type'=>'hidden',
      'name'=>'Typ',
      'field'=>'id_page',
      'default'=>(int)$_GET["idsys_page"],
    );
      $wh = ' AND photogallerys.id_page = '.$_GET["idsys_page"];
  }
  
  $args=array(
    'name'=>'Fotogalerie',
    'table'=>'photogallery',  
    'item_title'=>'pl.name',    
    'documents'=>TRUE,
    'actions'=>$actions,
    'join'=>' LEFT JOIN photogallerys_languages AS pl ON (pl.id_photogallery=photogallerys.id)',
    'where'=>' AND pl.id_language=1'.$wh,
    'groupby'=>'id',
    'thumb_directory'=>'thumb-s',
    'ftp'=>$GLOBALS['ftp'],
    'items'=>array(
       $type,
      array(
        'type'=>'multireference',
        'name'=>'Obsah',
        'mrtable'=>'photogallerys_languages',
        'mrkey'=>'id_photogallery',
        'mrfkey'=>'id_language',
        'ftable'=>'languages',
        'ffield'=>'name',
        'fkey'=>'id',
        'data'=>array(
        array(
         'type'=>'text',
         'name'=>'Název',
         'field'=>'name',
          'default'=>'',
         'reg'=>'^.+$',
       ),
       array(
         'type'=>'wysiwyg',
         'name'=>'Popis',
          'field'=>'description',
          'default'=>'',
          'reg'=>'^.*$',
        ),
        ),
      ),
    
      array(
        'type'=>'void',
        'name'=>'Název CZ',
        'field'=>'name',
        'table'=>'pl',
      ),
    ),
    'list'=>array(
      'columns'=>array(
        array(
          'name'=>'Název',
          'field'=>'Název CZ',
          'sort'=>'name',
          'href'=>'this',
          'width'=>'130',
        ),
      ),
    ),
  );
  

  

  
  $admin=new Admin($args);

  
 // $admin->innerHTML['detail']['top']=$admin->innerHTML['detail']['bottom']='<br /><a href="newsletter-write.php?new='.$admin->id.'" class="button">Odeslat newsletterem</a>';

  
  $result.=$admin->getHTML(); 
      
      return $result;
    }
  
  
  
  
  
  
  
  // frontend
  
  
   function frontEnd(&$cms, $type)

  {

    $result='';
    $ftp = $GLOBALS['ftp'];

    

  

    if (TRUE==isset($_GET['id']))
    {
    $id=$_GET['id'];
    }
    else
    {
    $id='';
    }

    

    if (TRUE==$id){

     
           $pp=$cms->db->select(

        'f.path, f.name as filename, p.id, p.year, pl.name',

        'photogallerys as  p

        LEFT JOIN photogallerys_languages as pl on (pl.id_photogallery = p.id)

        LEFT JOIN files as f on (f.id = p.preview)',

        'pl.id_language ='.(int)$cms->language['id'].' AND p.active ="Y" AND p.id_page = '.(int)$type.' and p.id="'.$id.'"',

        '',

        'p.create_time desc'

      );
     
    
    
    
     
     
      $p=$cms->db->select(

        'f.path, f.name as filename',
        'photogallerys_files as  pf
        LEFT JOIN files as f on (f.id = pf.id_file)',
          'pf.id_photogallery = '.$id.' and path<>"'.$pp[0]['path'].'"',

        '',

        'f.list asc'

      );

       
        $p_str='
        
        
               <div class="clear_both"></div>
        
            <div class="im">
          <div class="gallery-detail first">
            <a rel="example_group" href="'.$ftp['http_root'].'photogallery'.$id.'/'.$pp[0]['path'].'" title="'.$pp[0]["filename"].'">
            <img src="'.$ftp['http_root'].'photogallery'.$id.'/thumb-s/'.$pp[0]['path'].'" alt="'.stripslashes($pp[0]["filename"]).'" />
          </a>
        </div>
        </div>
        ';  

      $name = $cms->db->select('name, description','photogallerys_languages', 'id_language='.(int)$cms->language['id'].' AND id_photogallery ='.$id,'1');

      

      $cms -> page["name"] = stripslashes($name['name']);

      

      for($i=0;$i<count($p);$i++){
      
      
      
      
  
      
      
      
      
      
        $p_str.='
           <div class="im">
          <div class="gallery-detail '.$img.'">
            <a rel="example_group" href="'.$ftp['http_root'].'photogallery'.$id.'/'.$p[$i]['path'].'" title="'.$p[$i]["filename"].'">
            <img src="'.$ftp['http_root'].'photogallery'.$id.'/thumb-s/'.$p[$i]['path'].'" alt="'.stripslashes($p[$i]["filename"]).'" />
          </a>
        </div>
        </div>
        ';        

      }

      if (strip_tags(trim($name["description"]))==true){

        $result = ''.stripslashes($name["description"]).''.$p_str.'<p class="text_right">
        <div class="clear_both"><!-- --></div>
        
        <a href="?">Zpět na fotogalerii</a></p>';

      }else{

        $result = ''.stripslashes($name["description"]).''.$p_str.'<p class="text_right">
        
        <div class="clear_both"><!-- --></div>
        <a href="?">Zpět na fotogalerii</a></p>';

      }

            

    return $result .'<hr class="cl" /> ';

    

    

    

    

    }else{


     
     $zjistis=array ();
     $zjistis=$cms->db->select('*','photogallerys','id_page="'.$type.'"');
     
     
     
     $id=$zjistis[0]['id'];
     
     
           $pp=$cms->db->select(

        'f.path, f.name as filename, p.id, p.year, pl.name',

        'photogallerys as  p

        LEFT JOIN photogallerys_languages as pl on (pl.id_photogallery = p.id)

        LEFT JOIN files as f on (f.id = p.preview)',

        'pl.id_language ='.(int)$cms->language['id'].' AND p.active ="Y" AND p.id_page = '.(int)$type.' and p.id="'.$id.'"',

        '',

        'p.list asc'

      );
     
    
    
    
     
 
      $p=$cms->db->select(

        'f.path, f.name as filename',
        'photogallerys_files as  pf
        LEFT JOIN files as f on (f.id = pf.id_file)',
          'pf.id_photogallery = '.$id.' and path<>"'.$pp[0]['path'].'"',

        '',

        'f.list asc'

      );
        
       
        $p_str='
        
        
               <div class="clear_both"></div>
        
            <div class="im">
          <div class="gallery-detail first">
            <a rel="example_group" href="'.$ftp['http_root'].'photogallery'.$id.'/thumb-l/'.$pp[0]['path'].'" title="'.$pp[0]["filename"].'">
            <img src="'.$ftp['http_root'].'photogallery'.$id.'/thumb-s/'.$pp[0]['path'].'" alt="'.stripslashes($pp[0]["filename"]).'" />
          </a>
        </div>
        </div>
        ';  

      $name = $cms->db->select('name, description','photogallerys_languages', 'id_language='.(int)$cms->language['id'].' AND id_photogallery ='.$id,'1');

      

      $cms -> page["name"] = stripslashes($name['name']);

      

      for($i=0;$i<count($p);$i++){
      
      
      
      
  
      
      
      
      
      
        $p_str.='
           <div class="im">
          <div class="gallery-detail '.$img.'">
            <a rel="example_group" href="'.$ftp['http_root'].'photogallery'.$id.'/thumb-l/'.$p[$i]['path'].'" title="'.$p[$i]["filename"].'">
            <img src="'.$ftp['http_root'].'photogallery'.$id.'/thumb-s/'.$p[$i]['path'].'" alt="'.stripslashes($p[$i]["filename"]).'" />
          </a>
        </div>
        </div>
        ';        

      }

      if (strip_tags(trim($name["description"]))==true){

        $result = ''.stripslashes($name["description"]).''.$p_str.'<p class="text_right">
        <div class="clear_both"><!-- --></div>
        
      </p>';

      }else{

        $result = ''.stripslashes($name["description"]).''.$p_str.'<p class="text_right">
        
        <div class="clear_both"><!-- --></div>
       </p>';

      }

            

    return $result .'<hr class="cl" /> ';

}

    
return $result.' <hr class="cl" />';

                 

  }
  
  
  
function frontEndPreview(&$cms, $limit=3)
  {
    $result='';
    $ftp = $GLOBALS['ftp'];
    
 
    $ph=$cms->db->select(
      'f.path as fpath, f.name as filename, p.id',
      'photogallerys as  p
      LEFT JOIN photogallerys_files as pf on (pf.id_photogallery = p.id)
      LEFT JOIN files as f on (f.id = pf.id_file)',
      'p.active = "Y" and f.id is not null',
      $limit,
      'f.id desc'
    );
    
    $img = '';  
    for ($i=0;$i< count($ph);$i++){  
      $img .= '
        <a class="rel" href="'.$cms->httpRoot.'files/photogallery'.$ph[$i]['id'].'/'.$ph[$i]['fpath'].'" title="'.$ph[$i]["filename"].'">
        <img src="'.$cms->httpRoot.'files/photogallery'.$ph[$i]['id'].'/user2/'.$ph[$i]['fpath'].'" alt="'.$ph[$i]["filename"].'" />
        </a>
       ';    
    }
    
    $result ='
    <div id="last_photo" class="centr">
    '.$img.'
    </div>
    ';
    
  
    return $result;
  
  }


 
  
  
  
  
  }
  
?>

ACC SHELL 2018