function streamFile($arquivoId, $type, $screenSize)
{
    global $smarty;
    require_once "lib/persistentObj/PersistentObjectFactory.php";
    $objResponse = new xajaxResponse();
    if (!$arquivoId) {
        return $objResponse;
    }
    $arquivo = PersistentObjectFactory::createObject("Publication", (int) $arquivoId);
    $file =& $arquivo->filereferences[0];
    $file->hitStream();
    $screenSize -= 250;
    if ($type == 'Imagem') {
        $smarty->assign('src', $file->baseDir . $file->fileName);
        if ($file->width > $screenSize) {
            $file->height = $screenSize * ($file->height / $file->width);
            $file->width = $screenSize;
            $smarty->assign('note', tra("Imagem redimensionada"));
        } else {
            $smarty->assign('note', '');
        }
        $objResponse->remove('ajax-gPlayerImagem');
        $objResponse->append('ajax-contentBubble', 'innerHTML', $smarty->fetch('el-playerImage.tpl'));
        $objResponse->assign('ajax-gImagem', 'style.maxWidth', $screenSize . "px");
        $objResponse->assign('ajax-gPlayerImagem', 'style.width', $file->width . "px");
        $objResponse->assign('ajax-gPlayerImagem', 'style.height', $file->height . "px");
        $objResponse->script("showLightbox('ajax-gPlayerImagem')");
        return $objResponse;
    }
    $validUrl = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    $validUrl = preg_replace('/el-.+\\.php.*$/', '', $validUrl);
    $validUrl .= $file->baseDir . $file->fileName;
    if ($type == 'Video') {
        $width = $file->width;
        $height = $file->height;
        $video = "true";
    } else {
        $width = 200;
        $height = 20;
        $video = "false";
    }
    /*pra quando rolar tutoriais em swf
       * if (preg_match('/.*\.swf$/i', $arquivo.arquivo)) {
      	$smarty->assign('src', 'repo/' . $arquivo['arquivo']);
      	$objResponse->remove('gPlayerSwf');
      	$objResponse->append('ajax-contentBubble', 'innerHTML', $smarty->fetch('el-playerSwf.tpl'));
      	$objResponse->script("showLightbox('gPlayerSwf')");	
      } else {
      */
    $objResponse->remove('ajax-gPlayer');
    $objResponse->append('ajax-contentBubble', 'innerHTML', $smarty->fetch('el-player.tpl'));
    $objResponse->script("loadFile('{$validUrl}', {$width}, {$height}, '{$video}')");
    //}
    return $objResponse;
}
function smarty_function_el_gallery_item($params, &$smarty)
{
    $id = $params['id'];
    if (!$id) {
        return '';
    }
    global $smarty;
    require_once "lib/persistentObj/PersistentObjectFactory.php";
    $arquivo = PersistentObjectFactory::createObject("Publication", (int) $id);
    $smarty->assign_by_ref('arquivo', $arquivo);
    return $smarty->fetch('el-gallery_list_item.tpl');
}
function delete_file($arquivoId)
{
    global $user;
    require_once "lib/persistentObj/PersistentObjectFactory.php";
    $arquivo = PersistentObjectFactory::createObject("Publication", (int) $arquivoId);
    $objResponse = new xajaxResponse();
    if (!isset($arquivo->user) || $arquivo->user != $user) {
        return $objResponse;
    }
    $arquivo->delete();
    $objResponse->remove("ajax-pendente-{$arquivoId}");
    return $objResponse;
}
 function findOne($filters = array())
 {
     $queryParams = $this->_prepQueryConditions($filters);
     $result = $this->query("select {$this->table}.id from " . $queryParams[0] . $queryParams[1], $queryParams[2]);
     if ($row = $result->fetchRow()) {
         // agora retorna um objeto e nao a linha do resultado da query - bgola
         return PersistentObjectFactory::createObject($this->controlledClass, (int) $row['id']);
     }
     return false;
 }
function deleteFileReference($i, $fileId)
{
    global $arquivo;
    if ($arquivo->mainFile == (int) $i) {
        $arquivo->update(array('mainFile' => NULL));
    }
    if ($arquivo->mainFile > (int) $i) {
        $arquivo->update(array('mainFile' => $arquivo->mainFile--));
    }
    require_once "lib/persistentObj/PersistentObjectFactory.php";
    $file = PersistentObjectFactory::createObject("FileReference", (int) $fileId);
    $file->delete();
    $objResponse = new xajaxResponse();
    $objResponse->remove("ajax-file{$i}");
    return $objResponse;
}
$actualClass = array("Video" => "VideoPublication", "Audio" => "AudioPublication", "Imagem" => "ImagePublication", "Texto" => "TextPublication");
$filters["actualClass"] = array();
foreach ($type as $tipo) {
    $filters["actualClass"][] = $actualClass[$tipo];
}
$filters["publishDate"] = true;
if (!isset($_REQUEST['tag']) && isset($_REQUEST['tags'])) {
    $_REQUEST['tag'] = $_REQUEST['tags'];
}
$files = array();
if (isset($_REQUEST['tag']) && $_REQUEST['tag']) {
    $tagArray = split(",", $_REQUEST['tag']);
    $title .= " - Tags: " . $_REQUEST['tag'];
    $objects = $freetaglib->get_objects_with_tag_combo($tagArray, 'gallery', $userName);
    foreach ($objects['data'] as $object) {
        $arquivo = PersistentObjectFactory::createObject("Publication", (int) $object['itemId']);
        if (in_array($arquivo->type, $type)) {
            $files[] = $arquivo;
        }
    }
} else {
    $controller = new PersistentObjectController("Publication");
    $files = $controller->findAll($filters, 0, $maxRecords, $dateId . '_desc');
}
$uniqueid = $feed . $userName . $maxRecords . implode('', $type);
$changes = array();
$changes["data"] = array();
for ($i = 0; $i < sizeof($files); $i++) {
    if (sizeof($files[$i]->filereferences)) {
        $arquivo = array();
        $file =& $files[$i]->filereferences[0];
 function _getChildren($type = false)
 {
     foreach ($this->hasMany as $child => $parent) {
         $childName = strtolower($child);
         if (!$type || $childName == strtolower($type)) {
             require_once $child . ".php";
             $idName = strtolower($parent) . "Id";
             $result = $this->query("select id from {$childName} where {$idName} = ?", array($this->id));
             $children = array();
             while ($row = $result->fetchRow()) {
                 array_push($children, PersistentObjectFactory::createObject($child, (int) $row['id'], true));
             }
             $this->_setValue($childName . "s", $children);
         }
     }
 }
Esempio n. 8
0
require_once("tiki-setup.php");
require_once("lib/persistentObj/PersistentObjectFactory.php");

// compativel com os links antigos
if (isset($_REQUEST['arquivo']) && !isset($_REQUEST['pub'])) {
	$_REQUEST['pub'] = $_REQUEST['arquivo'];
	$_REQUEST['file'] = 0;
}

if (!isset($_REQUEST['pub']) || $_REQUEST['pub'] == 0) {
    $smarty->assign('msg', tra("Publicação inexistente"));
    $smarty->display("error.tpl");
    die;
}

$pub = PersistentObjectFactory::createObject("Publication", (int)$_REQUEST['pub']);

if (isset($_REQUEST['file'])) {
	$file =& $pub->filereferences[(int)$_REQUEST['file']];
	$file->hitDownload();
	$location = $file->fullPath();
    if ($file->mimeType == 'audio/mpeg') addMp3Headers($location, $file->size); //para forçar o download
} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'downloadAll') {
	if (count($pub->filereferences) == 1) {
		$file =& $pub->filereferences[0];
		$file->hitDownload();
		$location = $file->fullPath();
        if ($file->mimeType == 'audio/mpeg') addMp3Headers($location, $file->size); //para forçar o download
	} else {
		$fileList = "";
		foreach ($pub->filereferences as $file) {
function retrieveFileInfo($id)
{
    require_once "lib/persistentObj/PersistentObjectFactory.php";
    return PersistentObjectFactory::createObject("Publication", (int) $id);
}