⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 photos.php

📁 这是一个joomla系统的插件, 这是一个joomla系统的插件
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?php/*** @package EasyGallery* @copyright (C) 2006 Joomla-addons.org* @author  Adam van Dongen* @version $Id: photos.php 9 2007-06-22 13:22:10Z websmurf $* * --------------------------------------------------------------------------------* All rights reserved. Easy Gallery Component for Joomla!** This program is free software; you can redistribute it and/or* modify it under the terms of the Joomla-addons Free Software License * See LICENSE.php for more information.** This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  * --------------------------------------------------------------------------------**/defined( '_VALID_MOS' ) or die( 'Restricted access' );set_time_limit(0); //run as long as neededclass photos {    /**   * Show all photo's   *   */  function show() {    global $database, $mainframe, $option;      	$limit = intval( $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mainframe->getCfg('list_limit') ) );  	$limitstart	= intval( $mainframe->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 ) );  	$cid	= intval( $mainframe->getUserStateFromRequest( "view{$option}cid", 'cid', 0 ) );  	  	$where = array();  	if($cid > 0){  	  $where[] = 'g.cid = ' . $cid;  	}  	  	$basequery = "SELECT %s FROM #__easygallery g   	  LEFT JOIN #__categories c ON g.cid = c.id ";  	if(sizeof($where) > 0){  	  $basequery .= "WHERE " . implode(" AND ", $where);  	}  	$basequery .= " ORDER BY cid, g.ordering";  	  	$query = str_replace('%s', 'COUNT(1)', $basequery);  	$database->setQuery($query);  	$total = $database->loadResult();  	  	require_once($mainframe->getCfg('absolute_path') . '/administrator/includes/pageNavigation.php');  	$pageNav = new mosPageNav($total, $limitstart, $limit);  	  	$query = str_replace("%s", "g.*, c.name AS category", $basequery) . ' LIMIT ' . $limitstart . ', ' . $limit;  	$database->setQuery($query);  	$rows = $database->loadObjectList();  	echo $database->getErrorMsg();  	  	$categories = categories::getCategorieTree();  	  	$obj = new stdClass();  	$obj->id = 0;  	$obj->name = ' - all - ';  	  	array_unshift($categories, $obj);  	  	$lists = array();  	$lists['cid'] = mosHTML::selectList($categories, 'cid', 'onchange="document.adminForm.submit();"', 'id', 'name', $cid);  	  	HTML_easygallery::showPhotos($rows, $pageNav, $lists);  }    /**   * Edit photo   *   * @param int $id   */  function edit($id){    global $database;        $row = new dbPhoto($database);    $row->load($id);        $categories = categories::getCategorieTree();  	  	$obj = new stdClass();  	$obj->id = 0;  	$obj->name = ' - select - ';  	  	array_unshift($categories, $obj);        $lists = array();  	$lists['cid'] = mosHTML::selectList($categories, 'cid', '', 'id', 'name', $row->cid);        HTML_easygallery::editPhoto($row, $lists);  }    /**   * Save photo changes   *   */  function save(){    global $option, $database, $task;        $row = new dbPhoto($database);    $row->bind($_POST);        $row->default = intval(mosGetParam($_REQUEST, 'default', 0));        if($row->default){		  $query = 'UPDATE #__easygallery SET `default` = 0 WHERE cid = ' . (int) $row->cid;		  $database->setQuery($query);		  $database->query();		  echo $database->getErrorMsg();		}        if(!$row->id){      $row->ordering = 999999999;    }        if (!$row->check()) {			echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";			exit();		}		if (!$row->store()) {			echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";			exit();		}				$row->updateOrder('cid = ' . (int) $row->cid);		switch ($task){		  case 'save':		    mosRedirect('index2.php?option=' . $option . '&act=photos', 'Changes to photo saved');		    break;		  case 'apply':		    mosRedirect('index2.php?option=' . $option . '&act=photos&task=edit&cid=' . $row->id . '&hidemainmenu=1', 'Changes to photo saved');		    break;		}  }    /**   * Remove selected photo's   *   * @param array $ids   */  function remove($ids, $redirect = true){    global $database, $option, $eg_ftp_path, $eg_image_path, $eg_original_path, $eg_thumbnail_path, $eg_ftp_disabled, $mainframe;        $row = new dbPhoto($database);    $ftp = new egftp();        for($i=0,$n=count($ids);$i<$n;$i++){      $id = intval($ids[$i]);            $row->load($id);            if($eg_ftp_disabled == 0){        if(file_exists($mainframe->getCfg('absolute_path') . '/' . $eg_image_path . '/' . $row->path)){          $ftp->del($row->path);        }        if($mainframe->getCfg('absolute_path') . '/' . $eg_thumbnail_path . '/' . $row->path){          $ftp->del($eg_ftp_path . $eg_thumbnail_path . '/' . $row->path);        }        if($mainframe->getCfg('absolute_path') . '/' . $eg_original_path . '/' . $row->path){          $ftp->del($eg_ftp_path . $eg_original_path . '/' . $row->path);        }      } else {        if(file_exists($mainframe->getCfg('absolute_path') . '/' . $eg_image_path . '/' . $row->path)){          if(!unlink($mainframe->getCfg('absolute_path') . '/' . $eg_image_path . '/' . $row->path)){            echo "<script> alert('Failed to remove image: ". $mainframe->getCfg('absolute_path') . '/' . $eg_image_path . '/' . $row->path . "'); window.history.go(-1); </script>\n";    			  exit();          }        }        if(file_exists($mainframe->getCfg('absolute_path') . '/' . $eg_thumbnail_path . '/' . $row->path)){          if(!unlink($mainframe->getCfg('absolute_path') . '/' . $eg_thumbnail_path . '/' . $row->path)){            echo "<script> alert('Failed to remove image: ". $mainframe->getCfg('absolute_path') . '/' . $eg_thumbnail_path . '/' . $row->path . "'); window.history.go(-1); </script>\n";    			  exit();          }        }        if(file_exists($mainframe->getCfg('absolute_path') . '/' . $eg_original_path . '/' . $row->path)){          if(!unlink($mainframe->getCfg('absolute_path') . '/' . $eg_original_path . '/' . $row->path)){            echo "<script> alert('Failed to remove image: ". $mainframe->getCfg('absolute_path') . '/' . $eg_original_path . '/' . $row->path . "'); window.history.go(-1); </script>\n";    			  exit();          }        }      }            $cid = $row->cid;            $row->delete();            $row->updateOrder('cid = ' . $cid);    }        if($redirect){      mosRedirect('index2.php?option=' . $option . '&act=photos', 'Selected items have been removed');    } else {      return $cid;    }  }    /**   * Set a Photo state   *   * @param array ids   * @param int state   */  function setState($ids, $state){    global $database, $option;        $row = new dbPhoto($database);        for($i=0,$n=count($ids);$i<$n;$i++){          $row->load($ids[$i]);          $row->state = $state;          if (!$row->store()) {			  echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";			  exit();		  }    }        mosRedirect('index2.php?option=' . $option . '&act=photos');  }    /**   * Move an item up or down   *   * @param int $id   * @param int $direction   */  function reorder($id, $direction){    global $database, $option;        $row = new dbPhoto($database);    $row->load($id);        $row->move($direction, 'cid = ' . (int) $row->cid);        mosRedirect('index2.php?option=' . $option . '&act=photos');  }    /**   * Change ordering of a lot of items   *   * @param array $cid   */  function saveOrder($cid){    global $database, $option;        $order = mosGetParam( $_POST, 'order', array(0) );    $row = new dbPhoto($database);    $conditions = array();        for($i=0,$n=count($cid);$i<$n;$i++){			$row->load($cid[$i]);						if ($row->ordering != $order[$i]) {				$row->ordering = $order[$i];								if (!$row->store()) {				  echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";  				exit();				}								$condition = 'cid = ' . (int) $row->cid;				$found = false;								for($j=0,$k=count($conditions);$j<$k;$j++){				  $cond = $conditions[$j];				  if ($cond[1] == $condition) {						$found = true;						break;					}				}			  if (!$found){				  $conditions[] = array ($row->id, $condition);				}			}		}		for($i=0,$n=count($conditions);$i<$n;$i++){		  $condition = $conditions[$i];		  			$row->load($condition[0]);			$row->updateOrder($condition[1]);		}				mosRedirect('index2.php?option=' . $option . '&act=photos');  }    /**   * Display upload form   *   */  function upload(){    global $database;        $lists = array();    $categories = categories::getCategorieTree();    $lists['cid'] = mosHTML::selectList($categories, 'cid', 'class="inputbox text_area"', 'id', 'name');        $options = array(      mosHTML::makeOption('name', 'Sort by name - A-Z'),      mosHTML::makeOption('rname', 'Sort by name - Z-A'),      mosHTML::makeOption('c_date', 'Sort by created date'),      mosHTML::makeOption('m_date', 'Sort by modified date')    );    $lists['sort'] = mosHTML::selectList($options, 'sort', 'class="inputbox text_area"', 'value', 'text', 'name');        HTML_easygallery::upload($lists);  }    /**   * Proccess images after upload   *   */  function handleUpload($redirect = true){    global $option, $database, $mainframe;        $ftp = new egftp();        $cid = mosGetParam($_REQUEST, 'cid', 0);    $state = mosGetParam($_REQUEST, 'state', 0);    $description = mosGetParam($_REQUEST, 'description', '', _MOS_ALLOWHTML);    $imagename = mosGetParam($_REQUEST, 'name', '');    $sort = mosGetParam($_REQUEST, 'sort', 'name');    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -