function display($tpl = null) { $this->t = PhocaDownloadUtils::setVars('cat'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); // Preprocess the list of items to find ordering divisions. foreach ($this->items as &$item) { $this->ordering[$item->parent_id][] = $item->id; } // We need to load all items because of creating tree // After creating tree we get info from pagination // and will set displaying of categories for current pagination //E.g. pagination is limitstart 5, limit 5 - so only categories from 5 to 10 will be displayed if (!empty($this->items)) { $text = ''; // text is tree name e.g. Category >> Subcategory $tree = array(); $this->items = $this->processTree($this->items, $tree, 0, $text, -1, 0); } //$this->tmpl['notapproved'] = $this->get( 'NotApprovedCategory' ); JHTML::stylesheet($this->t['s']); $this->addToolbar(); parent::display($tpl); }
public function display($tpl = null) { $this->t = PhocaDownloadUtils::setVars('cat'); $this->state = $this->get('State'); $this->form = $this->get('Form'); $this->item = $this->get('Item'); $user = JFactory::getUser(); $model = $this->getModel(); JHTML::_('behavior.calendar'); JHTML::stylesheet($this->t['s']); //Data from model //$this->item =& $this->get('Data'); $lists = array(); $isNew = (int) $this->item->id == 0; // Edit or Create? if (!$isNew) { $model->checkout($user->get('id')); } else { // Initialise new record $this->item->approved = 1; $this->item->published = 1; $this->item->order = 0; $this->item->access = 0; } $this->addToolbar(); parent::display($tpl); }
public function display($tpl = null) { $this->t = PhocaDownloadUtils::setVars('style'); JHTML::stylesheet($this->t['s']); $this->state = $this->get('State'); $this->item = $this->get('Item'); $this->form = $this->get('Form'); $this->ftp = JClientHelper::setCredentialsFromRequest('ftp'); $model = $this->getModel(); // Set CSS for codemirror JFactory::getApplication()->setUserState('editor.source.syntax', 'css'); // New or edit if (!$this->form->getValue('id') || $this->form->getValue('id') == 0) { $this->form->setValue('source', null, ''); $this->form->setValue('type', null, 2); $this->t['ssuffixtype'] = JText::_($this->t['l'] . '_WILL_BE_CREATED_FROM_TITLE'); } else { $this->source = $model->getSource($this->form->getValue('id'), $this->form->getValue('filename'), $this->form->getValue('type')); $this->form->setValue('source', null, $this->source->source); $this->t['ssuffixtype'] = ''; } // Only help input form field - to display Main instead of 1 and Custom instead of 2 if ($this->form->getValue('type') == 1) { $this->form->setValue('typeoutput', null, JText::_($this->t['l'] . '_MAIN_CSS')); } else { $this->form->setValue('typeoutput', null, JText::_($this->t['l'] . '_CUSTOM_CSS')); } if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->addToolbar(); parent::display($tpl); }
public static function displayMirrorLinks($view = 1, $link, $title, $target) { $paramsC = JComponentHelper::getParams('com_phocadownload'); $param['display_mirror_links'] = $paramsC->get('display_mirror_links', 0); $o = ''; $displayM = 0; if ($view == 1) { //Category View if ($param['display_mirror_links'] == 1 || $param['display_mirror_links'] == 3 || $param['display_mirror_links'] == 4 || $param['display_mirror_links'] == 6) { $displayM = 1; } } else { //File View if ($param['display_mirror_links'] == 2 || $param['display_mirror_links'] == 3 || $param['display_mirror_links'] == 5 || $param['display_mirror_links'] == 6) { $displayM = 1; } } if ($displayM == 1 && $link != '' && PhocaDownloadUtils::isURLAddress($link) && $title != '') { $targetO = ''; if ($target != '') { $targetO = 'target="' . $target . '"'; } $o .= '<a class="" href="' . $link . '" ' . $targetO . '>' . strip_tags($title) . '</a>'; } return $o; }
function check() { if (empty($this->alias)) { $this->alias = $this->title; } $this->alias = PhocaDownloadUtils::getAliasName($this->alias); return true; }
function display($tpl = null) { $this->t = PhocaDownloadUtils::setVars(); JHTML::stylesheet($this->t['s']); JHTML::_('behavior.tooltip'); $class = $this->t['n'] . 'Utils'; $this->t['version'] = $class::getExtensionVersion(); $this->addToolbar(); parent::display($tpl); }
public function display($tpl = null) { $this->t = PhocaDownloadUtils::setVars('lic'); $this->state = $this->get('State'); $this->form = $this->get('Form'); $this->item = $this->get('Item'); JHTML::stylesheet($this->t['s']); $this->addToolbar(); parent::display($tpl); }
function display($tpl = null) { $this->t = PhocaDownloadUtils::setVars(); $this->views = array('files' => $this->t['l'] . '_FILES', 'cats' => $this->t['l'] . '_CATEGORIES', 'lics' => $this->t['l'] . '_LICENSES', 'stat' => $this->t['l'] . '_STATISTICS', 'downloads' => $this->t['l'] . '_DOWNLOADS', 'uploads' => $this->t['l'] . '_UPLOADS', 'rafile' => $this->t['l'] . '_FILE_RATING', 'tags' => $this->t['l'] . '_TAGS', 'layouts' => $this->t['l'] . '_LAYOUT', 'styles' => $this->t['l'] . '_STYLES', 'logs' => $this->t['l'] . '_LOGGING', 'info' => $this->t['l'] . '_INFO'); JHTML::stylesheet($this->t['s']); JHTML::_('behavior.tooltip'); $class = $this->t['n'] . 'Utils'; $this->t['version'] = $class::getExtensionVersion(); $this->addToolbar(); parent::display($tpl); }
function display($tpl = null) { $this->t = PhocaDownloadUtils::setVars('cat'); $model = $this->getModel(); $this->items = $model->getItems(); $this->pagination = $model->getPagination(); $this->state = $model->getState(); /*$this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State');*/ // Preprocess the list of items to find ordering divisions. foreach ($this->items as &$item) { $this->ordering[$item->parent_id][] = $item->id; } // if search, don't do a tree, only display the searched items $this->t['search'] = $this->state->get('filter.search'); // We need to load all items because of creating tree // After creating tree we get info from pagination // and will set displaying of categories for current pagination //E.g. pagination is limitstart 5, limit 5 - so only categories from 5 to 10 will be displayed // the same for max levels $this->t['level'] = $this->state->get('filter.level'); if (!empty($this->items) && !$this->t['search']) { $text = ''; // text is tree name e.g. Category >> Subcategory $tree = array(); // Filter max levels if (isset($this->t['level']) && $this->t['level'] > 0) { $maxLevel = (int)$this->t['level'] + 1; } else { $maxLevel = false; } $this->items = $this->processTree($this->items, $tree, 0, $text, -1, 0, '', $maxLevel); // Re count the pagination $countTotal = count($this->items); $model->setTotal($countTotal); $this->pagination = $model->getPagination(); } //$this->tmpl['notapproved'] = $this->get( 'NotApprovedCategory' ); JHTML::stylesheet( $this->t['s'] ); $this->addToolbar(); parent::display($tpl); }
function check() { // check for valid name if (trim($this->title) == '') { $this->setError(JText::_('CATEGORY MUST HAVE A TITLE')); return false; } if (empty($this->alias)) { $this->alias = $this->title; } $this->alias = PhocaDownloadUtils::getAliasName($this->alias); return true; }
public function display($tpl = null) { $this->t = PhocaDownloadUtils::setVars('file'); $this->state = $this->get('State'); $this->form = $this->get('Form'); $this->item = $this->get('Item'); JHTML::stylesheet($this->t['s']); if (isset($this->item->textonly) && (int) $this->item->textonly == 1 && JRequest::getVar('layout') != 'edit_text') { $tpl = 'text'; } $this->addToolbar(); parent::display($tpl); }
function display($tpl = null) { $this->t = PhocaDownloadUtils::setVars('rafile'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); JHTML::stylesheet($this->t['s']); JHTML::stylesheet('media/com_phocadownload/css/administrator/rating.css'); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->addToolbar(); parent::display($tpl); }
function display($tpl = null) { $this->t = PhocaDownloadUtils::setVars('file'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); // Preprocess the list of items to find ordering divisions. foreach ($this->items as &$item) { $this->ordering[$item->catid][] = $item->id; } JHTML::stylesheet($this->t['s']); $this->tmpl['notapproved'] = $this->get('NotApprovedFile'); $this->addToolbar(); parent::display($tpl); }
function display($tpl = null) { $this->t = PhocaDownloadUtils::setVars('upload'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); JHTML::stylesheet($this->t['s']); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->addToolbar(); parent::display($tpl); }
function display($tpl = null) { $this->t = PhocaDownloadUtils::setVars('lic'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); // Preprocess the list of items to find ordering divisions. foreach ($this->items as &$item) { $this->ordering[0][] = $item->id; } JHTML::stylesheet($this->t['s']); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->addToolbar(); parent::display($tpl); }
function check() { // check for valid name but not by text if ((int) $this->textonly == 1) { } else { if (trim($this->filename) == '') { $this->setError(JText::_('FILE MUST HAVE A FILENAME')); return false; } } if (empty($this->title)) { $this->title = PhocaDownloadFile::getTitleFromFilenameWithoutExt($this->filename); } if (empty($this->alias)) { $this->alias = $this->title; } $this->alias = PhocaDownloadUtils::getAliasName($this->alias); return true; }
function display($tpl = null) { $this->t = PhocaDownloadUtils::setVars('stat'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->maxandsum = $this->get('MaxAndSum'); foreach ($this->items as &$item) { if ($item->textonly == 0) { $this->ordering[0][] = $item->id; } } JHTML::stylesheet($this->t['s']); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->addToolbar(); parent::display($tpl); }
function display($tpl = null) { $this->t = PhocaDownloadUtils::setVars('style'); $model = $this->getModel(); $model->checkItems(); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); JHTML::stylesheet($this->t['s']); foreach ($this->items as &$item) { $this->ordering[$item->type][] = $item->id; } // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->addToolbar(); parent::display($tpl); }
public function display($tpl = null) { $this->t = PhocaDownloadUtils::setVars('manager'); $this->field = JRequest::getVar('field'); $this->fce = 'phocaSelectFileName_' . $this->field; JHTML::stylesheet($this->t['s']); $this->folderstate = $this->get('FolderState'); $this->files = $this->get('Files'); $this->folders = $this->get('Folders'); $this->session = JFactory::getSession(); $this->manager = JRequest::getVar('manager', '', '', 'file'); if ($this->manager == 'filemultiple') { $this->form = $this->get('Form'); } $params = JComponentHelper::getParams($this->t['o']); $this->t['multipleuploadchunk'] = $params->get('multiple_upload_chunk', 0); $this->t['uploadmaxsize'] = $params->get('upload_maxsize', 3145728); $this->t['uploadmaxsizeread'] = PhocaDownloadFile::getFileSizeReadable($this->t['uploadmaxsize']); $this->t['enablemultiple'] = $params->get('enable_multiple_upload_admin', 0); $this->t['multipleuploadmethod'] = $params->get('multiple_upload_method', 1); $this->currentFolder = ''; if (isset($this->folderstate->folder) && $this->folderstate->folder != '') { $this->currentFolder = $this->folderstate->folder; } // - - - - - - - - - - //TABS // - - - - - - - - - - $this->t['tab'] = JRequest::getVar('tab', '', '', 'string'); $this->t['displaytabs'] = 0; // UPLOAD $this->t['currenttab']['upload'] = $this->t['displaytabs']; $this->t['displaytabs']++; // MULTIPLE UPLOAD if ((int) $this->t['enablemultiple'] >= 0) { $this->t['currenttab']['multipleupload'] = $this->t['displaytabs']; $this->t['displaytabs']++; } $group = PhocaDownloadSettings::getManagerGroup($this->manager); // - - - - - - - - - - - // Upload // - - - - - - - - - - - $sU = new PhocaDownloadFileUploadSingle(); $sU->returnUrl = 'index.php?option=com_phocadownload&view=phocadownloadmanager&tab=upload' . str_replace('&', '&', $group['c']) . '&manager=' . $this->manager . '&field=' . $this->field . '&folder=' . $this->currentFolder; $sU->tab = 'upload'; $this->t['su_output'] = $sU->getSingleUploadHTML(); $this->t['su_url'] = JURI::base() . 'index.php?option=com_phocadownload&task=phocadownloadupload.upload&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&viewback=phocadownloadmanager&manager=' . $this->manager . '&field=' . $this->field . '&' . 'folder=' . $this->currentFolder . '&tab=upload'; // - - - - - - - - - - - // Multiple Upload // - - - - - - - - - - - // Get infos from multiple upload $muFailed = JRequest::getVar('mufailed', '0', '', 'int'); $muUploaded = JRequest::getVar('muuploaded', '0', '', 'int'); $this->t['mu_response_msg'] = $muUploadedMsg = ''; if ($muUploaded > 0) { $muUploadedMsg = JText::_('COM_PHOCADOWNLOAD_COUNT_UPLOADED_FILE') . ': ' . $muUploaded; } if ($muFailed > 0) { $muFailedMsg = JText::_('COM_PHOCADOWNLOAD_COUNT_NOT_UPLOADED_FILE') . ': ' . $muFailed; } if ($muFailed > 0 && $muUploaded > 0) { $this->t['mu_response_msg'] = '<div class="alert alert-info">' . '<button type="button" class="close" data-dismiss="alert">×</button>' . JText::_('COM_PHOCADOWNLOAD_COUNT_UPLOADED_FILE') . ': ' . $muUploaded . '<br />' . JText::_('COM_PHOCADOWNLOAD_COUNT_NOT_UPLOADED_FILE') . ': ' . $muFailed . '</div>'; } else { if ($muFailed > 0 && $muUploaded == 0) { $this->t['mu_response_msg'] = '<div class="alert alert-error">' . '<button type="button" class="close" data-dismiss="alert">×</button>' . JText::_('COM_PHOCADOWNLOAD_COUNT_NOT_UPLOADED_FILE') . ': ' . $muFailed . '</div>'; } else { if ($muFailed == 0 && $muUploaded > 0) { $this->t['mu_response_msg'] = '<div class="alert alert-success">' . '<button type="button" class="close" data-dismiss="alert">×</button>' . JText::_('COM_PHOCADOWNLOAD_COUNT_UPLOADED_FILE') . ': ' . $muUploaded . '</div>'; } else { $this->t['mu_response_msg'] = ''; } } } if ((int) $this->t['enablemultiple'] >= 0) { PhocadownloadFileUploadMultiple::renderMultipleUploadLibraries(); $mU = new PhocaDownloadFileUploadMultiple(); $mU->frontEnd = 0; $mU->method = $this->t['multipleuploadmethod']; $mU->url = JURI::base() . 'index.php?option=com_phocadownload&task=phocadownloadupload.multipleupload&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&tab=multipleupload&manager=' . $this->manager . '&field=' . $this->field . '&folder=' . $this->currentFolder; $mU->reload = JURI::base() . 'index.php?option=com_phocadownload&view=phocadownloadmanager' . str_replace('&', '&', $group['c']) . '&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&tab=multipleupload&' . 'manager=' . $this->manager . '&field=' . $this->field . '&folder=' . $this->currentFolder; $mU->maxFileSize = PhocadownloadFileUploadMultiple::getMultipleUploadSizeFormat($this->t['uploadmaxsize']); $mU->chunkSize = '1mb'; $mU->renderMultipleUploadJS(0, $this->t['multipleuploadchunk']); $this->t['mu_output'] = $mU->getMultipleUploadHTML(); } $this->t['ftp'] = !JClientHelper::hasCredentials('ftp'); $this->t['path'] = PhocaDownloadPath::getPathSet($this->manager); $this->addToolbar(); parent::display($tpl); echo JHTML::_('behavior.keepalive'); }
protected function _addAllFilesFromFolder(&$existingImages, $category_id, $fullPath, $rel_path, $data = array()) { $count = 0; $fileList = JFolder::files($fullPath); natcasesort($fileList); // Iterate over the files if they exist //file - abc.img, file_no - folder/abc.img // Make a copy for play and preview (1) -------- if (isset($data['pap_copy_m']) && $data['pap_copy_m'] == 1) { $path = PhocaDownloadPath::getPathSet(); $storedfoldername = ltrim(str_replace(DS, '/', JPath::clean($rel_path)), '/'); $paramsC = JComponentHelper::getParams('com_phocadownload'); $overwriteExistingFiles = $paramsC->get('overwrite_existing_files', 0); } // ------------------------------------------------ if ($fileList !== false) { foreach ($fileList as $filename) { $storedfilename = ltrim(str_replace(DS, '/', JPath::clean($rel_path . DS . $filename)), '/'); //$ext = strtolower(JFile::getExt($filename)); if (JFile::exists($fullPath . DS . $filename) && substr($filename, 0, 1) != '.' && strtolower($filename) !== 'index.html' && !$this->_FileExist($existingImages, $storedfilename, $category_id)) { $row =& $this->getTable('phocadownload'); $datam = array(); $datam['published'] = $data['published']; $datam['catid'] = $category_id; $datam['filename'] = $storedfilename; $datam['approved'] = $data['approved']; $datam['language'] = $data['language']; if ($data['title'] != '') { $datam['title'] = $data['title']; } else { $datam['title'] = PhocaDownloadFile::getTitleFromFilenameWithoutExt($filename); } if ($data['alias'] != '') { $datam['alias'] = $data['alias']; } else { $datam['alias'] = $data['alias']; //PhocaDownloadFile::get AliasName($datam['title']); } $datam['token'] = PhocaDownloadUtils::getToken($datam['title'] . $datam['filename']); $image = new JObject(); // Make a copy for play and preview (2) if (isset($data['pap_copy_m']) && $data['pap_copy_m'] == 1) { $o = $this->_copyPreviewAndPlay($filename, $storedfilename, $storedfoldername, $path, $overwriteExistingFiles); $datam['filename_play'] = $o['filename_play']; $datam['filename_preview'] = $o['filename_preview']; } // Save // Bind the form fields to the Phoca download table if (!$row->bind($datam)) { $this->setError($this->_db->getErrorMsg()); return false; } // Create the timestamp for the date $row->date = gmdate('Y-m-d H:i:s'); // if new item, order last in appropriate group if (!$row->id) { $where = 'catid = ' . (int) $row->catid; $row->ordering = $row->getNextOrder($where); } // Make sure the Phoca download table is valid if (!$row->check()) { $this->setError($this->_db->getErrorMsg()); return false; } // Store the Phoca download table to the database if (!$row->store()) { $this->setError($this->_db->getErrorMsg()); return false; } // -------------------------------------------- /*if ($this->firstImageFolder == '') { $this->setFirstImageFolder($row->filename); }*/ $image->filename = $storedfilename; $image->catid = $category_id; $existingImages[] =& $image; $count++; } } } // $this->setfileCount($count); return $count; }
function display($tpl = null) { $app = JFactory::getApplication(); $document = JFactory::getDocument(); $uri = JFactory::getURI(); $menus = $app->getMenu(); $menu = $menus->getActive(); $this->t['p'] = $app->getParams(); $user = JFactory::getUser(); $db = JFactory::getDBO(); $user = JFactory::getUser(); $userLevels = implode(',', $user->getAuthorisedViewLevels()); $this->t['pi'] = 'media/com_phocadownload/images/'; $this->t['pp'] = 'index.php?option=com_phocadownload&view=user&controller=user'; $this->t['pl'] = 'index.php?option=com_users&view=login&return=' . base64_encode($this->t['pp'] . '&Itemid=' . $app->input->get('Itemid', 0, 'int')); $neededAccessLevels = PhocaDownloadAccess::getNeededAccessLevels(); $access = PhocaDownloadAccess::isAccess($user->getAuthorisedViewLevels(), $neededAccessLevels); if (!$access) { $app->redirect(JRoute::_($this->t['pl'], false), JText::_("COM_PHOCADOWNLOAD_NOT_AUTHORISED_ACTION")); return; } PhocaDownloadRenderFront::renderAllCSS(); // = = = = = = = = = = = // PANE // = = = = = = = = = = = // - - - - - - - - - - // ALL TABS // - - - - - - - - - - // UCP is disabled (security reasons) if ((int) $this->t['p']->get('enable_user_cp', 0) == 0) { $app->redirect(JURI::base(false), JText::_("COM_PHOCADOWNLOAD_USER_UPLOAD_DISABLED")); exit; } $this->t['tab'] = $app->input->get('tab', 0, 'string'); $this->t['maxuploadchar'] = $this->t['p']->get('max_upload_char', 1000); $this->t['enableuseruploadapprove'] = $this->t['p']->get('enable_user_upload_approve', 0); $this->t['showpageheading'] = $this->t['p']->get('show_page_heading', 1); $this->t['uploadmaxsize'] = $this->t['p']->get('user_file_upload_size', 3145728); $this->t['uploadmaxsizeread'] = PhocaDownloadFile::getFileSizeReadable($this->t['uploadmaxsize']); $this->t['userfilesmaxcount'] = $this->t['p']->get('user_files_max_count', 5); $this->t['userfilesmaxsize'] = $this->t['p']->get('user_files_max_size', 20971520); $this->t['send_mail_upload'] = $this->t['p']->get('send_mail_upload', 0); $this->t['pw'] = PhocaDownloadRenderFront::renderPhocaDownload(); //Subcateogry //$this->t['parentid'] = $app->input->get('parentcategoryid', 0, 'int'); //$document->addScript(JURI::base(true).'/components/com_phocadownload/assets/js/comments.js'); $document->addCustomTag(PhocaDownloadRenderFront::renderOnUploadJS()); $document->addCustomTag(PhocaDownloadRenderFront::renderDescriptionUploadJS((int) $this->t['maxuploadchar'])); $document->addCustomTag(PhocaDownloadRenderFront::userTabOrdering()); $model = $this->getModel('user'); // Upload Form - - - - - - - - - - - - - - - $ftp = !JClientHelper::hasCredentials('ftp'); // Set FTP form $session = JFactory::getSession(); $this->assignRef('session', $session); // END Upload Form - - - - - - - - - - - - - $this->t['displayupload'] = 1; // - - - - - - - - - - // FORM // - - - - - - - - - - // No Controller because of returning back the values in case some form field is not OK // Set default for returning back $formData = new JObject(); $formData->set('title', ''); $formData->set('description', ''); $formData->set('author', ''); $formData->set('email', ''); $formData->set('license', ''); $formData->set('website', ''); $formData->set('version', ''); $this->t['errorcatid'] = ''; $this->t['erroremail'] = ''; $this->t['errorwebsite'] = ''; $this->t['errorfile'] = ''; $task = $app->input->get('task', '', 'string'); if ($task == 'upload') { $post['title'] = $app->input->get('phocadownloaduploadtitle', '', 'string'); $post['description'] = $app->input->get('phocadownloaduploaddescription', '', 'string'); $post['catidfiles'] = $app->input->get('catidfiles', 0, 'int'); $post['description'] = substr($post['description'], 0, (int) $this->t['maxuploadchar']); $post['approved'] = 0; $post['published'] = 1; $post['owner_id'] = $user->id; if ($this->t['enableuseruploadapprove'] == 0) { $post['approved'] = 1; } $post['author'] = $app->input->get('phocadownloaduploadauthor', '', 'string'); $post['email'] = $app->input->get('phocadownloaduploademail', '', 'string'); $post['website'] = $app->input->get('phocadownloaduploadwebsite', '', 'string'); $post['license'] = $app->input->get('phocadownloaduploadlicense', '', 'string'); $post['version'] = $app->input->get('phocadownloaduploadversion', '', 'string'); if ($post['title'] != '') { $formData->set('title', $post['title']); } if ($post['description'] != '') { $formData->set('description', $post['description']); } if ($post['author'] != '') { $formData->set('author', $post['author']); } if ($post['email'] != '') { $formData->set('email', $post['email']); } if ($post['website'] != '') { $formData->set('website', $post['website']); } if ($post['license'] != '') { $formData->set('license', $post['license']); } if ($post['version'] != '') { $formData->set('version', $post['version']); } //catid $returnForm = 0; if ($post['catidfiles'] < 1) { $this->t['errorcatid'] = JText::_('COM_PHOCADOWNLOAD_PLEASE_SELECT_CATEGORY'); $returnForm = 1; } jimport('joomla.mail.helper'); if ($post['email'] != '' && !JMailHelper::isEmailAddress($post['email'])) { $this->t['erroremail'] = JText::_('COM_PHOCADOWNLOAD_PLEASE_ENTER_VALID_EMAIL_ADDRESS'); $returnForm = 1; } if ($post['website'] != '' && !PhocaDownloadUtils::isURLAddress($post['website'])) { $this->t['errorwebsite'] = JText::_('COM_PHOCADOWNLOAD_PLEASE_ENTER_VALID_WEBSITE'); $returnForm = 1; } // Upload $errUploadMsg = ''; $redirectUrl = ''; $fileArray = JRequest::getVar('Filedata', '', 'files', 'array'); if (empty($fileArray) || isset($fileArray['name']) && $fileArray['name'] == '') { $this->t['errorfile'] = JText::_('COM_PHOCADOWNLOAD_PLEASE_ADD_FILE'); $returnForm = 1; } if ($post['title'] == '') { $post['title'] = PhocaDownloadFile::removeExtension($fileArray['name']); } $post['alias'] = PhocaDownloadUtils::getAliasName($post['title']); if ($returnForm == 0) { $errorUploadMsg = ''; if ($model->singleFileUpload($errorUploadMsg, $fileArray, $post)) { if ($this->t['send_mail_upload'] > 0) { PhocaDownloadMail::sendMail((int) $this->t['send_mail_upload'], $post['title'], 2); } $Itemid = $app->input->get('Itemid', 0, 'int'); $limitStart = $app->input->get('limitstart', 0, 'int'); if ($limitStart > 0) { $limitStartUrl = '&limitstart=' . $limitStart; } else { $limitStartUrl = ''; } $link = 'index.php?option=com_phocadownload&view=user&Itemid=' . $Itemid . $limitStartUrl; $app->redirect(JRoute::_($link, false), JText::_("COM_PHOCADOWNLOAD_SUCCESS_FILE_UPLOADED")); exit; } else { $this->t['errorfile'] = JText::_('COM_PHOCADOWNLOAD_ERROR_FILE_UPLOADED'); if ($errorUploadMsg != '') { $this->t['errorfile'] .= '<br />' . $errorUploadMsg; } } } } // - - - - - - - - - - - // FILES // - - - - - - - - - - - $this->t['filesitems'] = $model->getDataFiles($user->id); $this->t['filestotal'] = $model->getTotalFiles($user->id); $this->t['filespagination'] = $model->getPaginationFiles($user->id); $filter_state_files = $app->getUserStateFromRequest($this->_context_files . '.filter_state', 'filter_state', '', 'word'); $filter_catid_files = $app->getUserStateFromRequest($this->_context_files . '.filter_catid', 'filter_catid', 0, 'int'); $catid_files = $app->getUserStateFromRequest($this->_context_files . '.catid', 'catid', 0, 'int'); //$filter_sectionid_files = $app->getUserStateFromRequest( $this->_context_files.'.filter_sectionid', 'filter_sectionid', 0, 'int' ); $filter_order_files = $app->getUserStateFromRequest($this->_context_files . '.filter_order', 'filter_order', 'a.ordering', 'cmd'); $filter_order_Dir_files = $app->getUserStateFromRequest($this->_context_files . '.filter_order_Dir', 'filter_order_Dir', '', 'word'); $search_files = $app->getUserStateFromRequest($this->_context_files . '.search', 'search', '', 'string'); $search_files = JString::strtolower($search_files); // build list of categories $javascript = 'class="inputbox" size="1" onchange="document.phocadownloadfilesform.submit();"'; // get list of categories for dropdown filter $whereC = array(); //if ($filter_sectionid_files > 0) { // $whereC[] = ' cc.section = '.$db->Quote($filter_sectionid_files); //} //$whereC[] = "(cc.uploaduserid LIKE '%-1%' OR cc.uploaduserid LIKE '%".(int)$user->id."%')"; //$whereC[] = "(cc.uploaduserid LIKE '%-1%' OR cc.uploaduserid LIKE '%,{".(int)$user->id."}' OR cc.uploaduserid LIKE '{".(int)$user->id."},%' OR cc.uploaduserid LIKE '%,{".(int)$user->id."},%' OR cc.uploaduserid ={".(int)$user->id."} )"; $whereC[] = "(cc.uploaduserid LIKE '%-1%' OR cc.uploaduserid LIKE '%," . (int) $user->id . "' OR cc.uploaduserid LIKE '" . (int) $user->id . ",%' OR cc.uploaduserid LIKE '%," . (int) $user->id . ",%' OR cc.uploaduserid =" . (int) $user->id . " )"; $whereC = count($whereC) ? ' WHERE ' . implode(' AND ', $whereC) : ''; // get list of categories for dropdown filter $query = 'SELECT cc.id AS value, cc.title AS text, cc.parent_id as parentid' . ' FROM #__phocadownload_categories AS cc' . $whereC . ' ORDER BY cc.ordering'; $lists_files['catid'] = PhocaDownloadCategory::filterCategory($query, $catid_files, TRUE, TRUE, TRUE); /*$whereS = array(); //$whereS[] = "(cc.uploaduserid LIKE '%-1%' OR cc.uploaduserid LIKE '%".(int)$user->id."%')"; $whereS[] = "(cc.uploaduserid LIKE '%-1%' OR cc.uploaduserid LIKE '%,".(int)$user->id."' OR cc.uploaduserid LIKE '".(int)$user->id.",%' OR cc.uploaduserid LIKE '%,".(int)$user->id.",%' OR cc.uploaduserid =".(int)$user->id." )"; $whereS[] = 's.published = 1'; $whereS = ( count( $whereS ) ? ' WHERE '. implode( ' AND ', $whereS ) : '' ); // sectionid $query = 'SELECT s.title AS text, s.id AS value' . ' FROM #__phocadownload_sections AS s' . ' LEFT JOIN #__phocadownload_categories AS cc ON cc.section = s.id' . $whereS . ' GROUP BY s.id' . ' ORDER BY s.ordering'; // state filter /* $state_files[] = JHTML::_('select.option', '', '- '. JText::_( 'Select State' ) .' -' ); $state_files[] = JHTML::_('select.option', 'P', JText::_( 'Published' ) ); $state_files[] = JHTML::_('select.option', 'U', JText::_( 'Unpublished') ); $lists_image['state'] = JHTML::_('select.genericlist', $state_files, 'filter_state', 'class="inputbox" size="1" onchange="document.phocadownloadfilesform.submit();"', 'value', 'text', $filter_state );*/ //$lists_files['sectionid'] = PhocaDownloadCategory::filterSection($query, $filter_sectionid_files, TRUE); // state filter $lists_files['state'] = JHTML::_('grid.state', $filter_state_files); // table ordering $lists_files['order_Dir'] = $filter_order_Dir_files; $lists_files['order'] = $filter_order_files; // search filter $lists_files['search'] = $search_files; $this->t['catidfiles'] = $catid_files; $this->t['filestab'] = 1; // Tabs $displayTabs = 0; if ((int) $this->t['filestab'] == 0) { $currentTab['files'] = -1; } else { $currentTab['files'] = $displayTabs; $displayTabs++; } $this->t['displaytabs'] = $displayTabs; $this->t['currenttab'] = $currentTab; // ACTION $this->t['action'] = $uri->toString(); // SEF problem $isThereQM = false; $isThereQM = preg_match("/\\?/i", $this->t['action']); if ($isThereQM) { $amp = '&'; } else { $amp = '?'; } $this->t['actionamp'] = htmlspecialchars($this->t['action']) . $amp; $this->t['istheretab'] = false; $this->t['istheretab'] = preg_match("/tab=/i", $this->t['action']); $this->t['ps'] = '&tab=' . $this->t['currenttab']['files'] . '&limitstart=' . $this->t['filespagination']->limitstart; // ASIGN $this->assignRef('listsfiles', $lists_files); $this->assignRef('formdata', $formData); $this->assignRef('tmpl', $this->t); $this->assignRef('params', $this->t['p']); $session = JFactory::getSession(); $this->assignRef('session', $session); parent::display($tpl); }
public function displayVideo($url, $view = 0, $ywidth = 0, $yheight = 0) { $o = ''; if ($url != '' && PhocaDownloadUtils::isURLAddress($url)) { $shortUrl = 'http://youtu.be/'; $pos = strpos($url, $shortUrl); if ($pos !== false) { $code = str_replace($shortUrl, '', $url); } else { $codeArray = explode('=', $url); $code = str_replace($codeArray[0] . '=', '', $url); } if ($view == 0) { // Category View $youtubeheight = $this->params->get('youtube_height_cv', 240); $youtubewidth = $this->params->get('youtube_width_cv', 320); } else { // Detail View $youtubeheight = $this->params->get('youtube_height_dv', 360); $youtubewidth = $this->params->get('youtube_width_dv', 480); } if ((int) $ywidth > 0) { $youtubewidth = (int) $ywidth; } if ((int) $yheight > 0) { $youtubeheight = (int) $yheight; } $o .= '<object height="' . (int) $youtubeheight . '" width="' . (int) $youtubewidth . '">' . '<param name="movie" value="http://www.youtube.com/v/' . $code . '"></param>' . '<param name="allowFullScreen" value="true"></param>' . '<param name="allowscriptaccess" value="always"></param>' . '<embed src="http://www.youtube.com/v/' . $code . '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" height="' . (int) $youtubeheight . '" width="' . (int) $youtubewidth . '"></embed></object>'; } return $o; }
$oFileDesc = '<div class="pd-fdesc">' . PhocaDownloadUtils::strTrimAll($d) . '</div>'; break; case 5: $pdFileDescBottom = '<div class="pd-fdesc">' . $v->description . '</div>'; $oFileDesc = '<div class="pd-fdesc">' . PhocaDownloadUtils::strTrimAll($d) . '</div>'; break; case 6: $pdFileDescTop = '<div class="pd-fdesc">' . $d . '</div>'; $oFileDesc = '<div class="pd-fdesc">' . PhocaDownloadUtils::strTrimAll($d) . '</div>'; break; case 7: $pdFileDescBottom = '<div class="pd-fdesc">' . $d . '</div>'; $oFileDesc = '<div class="pd-fdesc">' . PhocaDownloadUtils::strTrimAll($d) . '</div>'; break; case 8: $oFileDesc = '<div class="pd-fdesc">' . PhocaDownloadUtils::strTrimAll($d) . '</div>'; break; default: break; } } // Detail Button if ($this->t['display_detail'] == 1) { if ($oFileDesc != '') { $overlibcontent = $oFileDesc; } else { $overlibcontent = $d; } $overlibcontent = str_replace('"', '\'', $overlibcontent); $sA = array(utf8_encode(chr(11)), utf8_encode(chr(160))); $eA = array("\t", "\n", "\r", "");
public function save($data) { // = = = = = = = = = = // Default VALUES FOR Rights in FRONTEND // ACCESS - 0: all users can see the category (registered or not registered) // if registered or not registered it will be set in ACCESS LEVEL not here) // if -1 - user was not selected so every registered or special users can see category // UPLOAD - -2: nobody can upload or add images in front (if 0 - every users can do it) // DELETE - -2: nobody can upload or add images in front (if 0 - every users can do it) if (!isset($data['accessuserid'])) { $data['accessuserid'] = array(); } if (!isset($data['uploaduserid'])) { $data['uploaduserid'] = array(); } if (!isset($data['deleteuserid'])) { $data['deleteuserid'] = array(); } $accessUserIdArray = PhocaDownloadUtils::toArray($data['accessuserid']); $uploadUserIdArray = PhocaDownloadUtils::toArray($data['uploaduserid']); $deleteUserIdArray = PhocaDownloadUtils::toArray($data['deleteuserid']); if (isset($data['access']) && (int) $data['access'] > 0 && (int) $accessUserIdArray[0] == 0) { $accessUserId[0] = -1; } $data['accessuserid'] = implode(',', $accessUserIdArray); $data['uploaduserid'] = implode(',', $uploadUserIdArray); $data['deleteuserid'] = implode(',', $deleteUserIdArray); // = = = = = = = = = = // Initialise variables; $dispatcher = JDispatcher::getInstance(); $table = $this->getTable(); $pk = !empty($data['id']) ? $data['id'] : (int) $this->getState($this->getName() . '.id'); $isNew = true; // Include the content plugins for the on save events. JPluginHelper::importPlugin('content'); // Load the row if saving an existing record. if ($pk > 0) { $table->load($pk); $isNew = false; } // Bind the data. if (!$table->bind($data)) { $this->setError($table->getError()); return false; } if (intval($table->date) == 0) { $table->date = JFactory::getDate()->toSql(); } // Prepare the row for saving $this->prepareTable($table); // Check the data. if (!$table->check()) { $this->setError($table->getError()); return false; } // Trigger the onContentBeforeSave event. /*$result = $dispatcher->trigger($this->event_before_save, array($this->option.'.'.$this->name, $table, $isNew)); if (in_array(false, $result, true)) { $this->setError($table->getError()); return false; }*/ // Store the data. if (!$table->store()) { $this->setError($table->getError()); return false; } // Clean the cache. $cache = JFactory::getCache($this->option); $cache->clean(); // Trigger the onContentAfterSave event. //$dispatcher->trigger($this->event_after_save, array($this->option.'.'.$this->name, $table, $isNew)); $pkName = $table->getKeyName(); if (isset($table->{$pkName})) { $this->setState($this->getName() . '.id', $table->{$pkName}); } $this->setState($this->getName() . '.new', $isNew); return true; }
public function onContentPrepare($context, &$article, &$params, $page = 0) { $document = JFactory::getDocument(); $db = JFactory::getDBO(); $iSize = $this->params->get('icon_size', 32); $iMime = $this->params->get('file_icon_mime', 0); $component = 'com_phocadownload'; $paramsC = JComponentHelper::getParams($component); $ordering = $paramsC->get('file_ordering', 1); // Start Plugin $regex_one = '/({phocadownload\\s*)(.*?)(})/si'; $regex_all = '/{phocadownload\\s*.*?}/si'; $matches = array(); $count_matches = preg_match_all($regex_all, $article->text, $matches, PREG_OFFSET_CAPTURE | PREG_PATTERN_ORDER); JHTML::stylesheet('media/com_phocadownload/css/main/phocadownload.css'); JHTML::stylesheet('media/plg_content_phocadownload/css/phocadownload.css'); // Start if count_matches if ($count_matches != 0) { $l = new PhocaDownloadLayout(); // Start CSS for ($i = 0; $i < $count_matches; $i++) { $view = ''; $id = ''; $text = ''; $target = ''; $playerwidth = $paramsC->get('player_width', 328); $playerheight = $paramsC->get('player_height', 200); $previewwidth = $paramsC->get('preview_width', 640); $previewheight = $paramsC->get('preview_height', 480); $playerheightmp3 = $paramsC->get('player_mp3_height', 30); $url = ''; $youtubewidth = 448; $youtubeheight = 336; $fileView = $paramsC->get('display_file_view', 0); $previewWindow = $paramsC->get('preview_popup_window', 0); $playWindow = $paramsC->get('play_popup_window', 0); $limit = 5; // Get plugin parameters $phocadownload = $matches[0][$i][0]; preg_match($regex_one, $phocadownload, $phocadownload_parts); $parts = explode("|", $phocadownload_parts[2]); $values_replace = array("/^'/", "/'\$/", "/^'/", "/'\$/", "/<br \\/>/"); foreach ($parts as $key => $value) { $values = explode("=", $value, 2); foreach ($values_replace as $key2 => $values2) { $values = preg_replace($values2, '', $values); } // Get plugin parameters from article if ($values[0] == 'view') { $view = $values[1]; } else { if ($values[0] == 'id') { $id = $values[1]; } else { if ($values[0] == 'text') { $text = $values[1]; } else { if ($values[0] == 'target') { $target = $values[1]; } else { if ($values[0] == 'playerwidth') { $playerwidth = (int) $values[1]; } else { if ($values[0] == 'playerheight') { $playerheight = (int) $values[1]; } else { if ($values[0] == 'playerheightmp3') { $playerheightmp3 = (int) $values[1]; } else { if ($values[0] == 'previewwidth') { $previewwidth = (int) $values[1]; } else { if ($values[0] == 'previewheight') { $previewheight = (int) $values[1]; } else { if ($values[0] == 'youtubewidth') { $youtubewidth = (int) $values[1]; } else { if ($values[0] == 'youtubeheight') { $youtubeheight = (int) $values[1]; } else { if ($values[0] == 'previewwindow') { $previewWindow = (int) $values[1]; } else { if ($values[0] == 'playwindow') { $playWindow = (int) $values[1]; } else { if ($values[0] == 'limit') { $limit = (int) $values[1]; } else { if ($values[0] == 'url') { $url = $values[1]; } } } } } } } } } } } } } } } } switch ($target) { case 'b': $targetOutput = 'target="_blank" '; break; case 't': $targetOutput = 'target="_top" '; break; case 'p': $targetOutput = 'target="_parent" '; break; case 's': $targetOutput = 'target="_self" '; break; default: $targetOutput = ''; break; } $output = ''; /* //Itemid $menu =& JSite::getMenu(); $itemSection= $menu->getItems('link', 'index.php?option=com_phocadownload&view=sections'); if(isset($itemSection[0])) { $itemId = $itemSection[0]->id; } else { $itemId = JRequest::getVar('Itemid', 1, 'get', 'int'); } */ switch ($view) { /* // - - - - - - - - - - - - - - - - // SECTIONS // - - - - - - - - - - - - - - - - case 'sections': if ($text !='') { $textOutput = $text; } else { $textOutput = JText::_('PLG_CONTENT_PHOCADOWNLOAD_DOWNLOAD_SECTIONS'); } $link = PhocaDownloadRoute::getSectionsRoute(); $output .= '<div class="phocadownloadsections'.(int)$iSize.'"><a href="'. JRoute::_($link).'" '.$targetOutput.'>'. $textOutput.'</a></div>'; break; // - - - - - - - - - - - - - - - - // SECTION // - - - - - - - - - - - - - - - - case 'section': if ((int)$id > 0) { $query = 'SELECT a.id, a.title, a.alias,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug' . ' FROM #__phocadownload_sections AS a' . ' WHERE a.id = '.(int)$id; $db->setQuery($query); $item = $db->loadObject(); if (isset($item->id) && isset($item->slug)) { if ($text !='') { $textOutput = $text; } else if (isset($item->title) && $item->title != '') { $textOutput = $item->title; } else { $textOutput = JText::_('PLG_CONTENT_PHOCADOWNLOAD_DOWNLOAD_SECTION'); } $link = PhocaDownloadRoute::getSectionRoute($item->id, $item->alias); // 'index.php?option=com_phocadownload&view=section&id='.$item->slug.'&Itemid='. $itemId $output .= '<div class="phocadownloadsection'.(int)$iSize.'"><a href="'. JRoute::_($link).'" '.$targetOutput.'>'. $textOutput.'</a></div>'; } } break; */ // - - - - - - - - - - - - - - - - // CATEGORIES // - - - - - - - - - - - - - - - - case 'categories': if ($text != '') { $textOutput = $text; } else { $textOutput = JText::_('PLG_CONTENT_PHOCADOWNLOAD_DOWNLOAD_CATEGORIES'); } $link = PhocaDownloadRoute::getCategoriesRoute(); $output .= '<div class="phocadownloadcategories' . (int) $iSize . '"><a href="' . JRoute::_($link) . '" ' . $targetOutput . '>' . $textOutput . '</a></div>'; break; // - - - - - - - - - - - - - - - - // CATEGORY // - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - // CATEGORY // - - - - - - - - - - - - - - - - case 'category': if ((int) $id > 0) { $query = 'SELECT a.id, a.title, a.alias,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug' . ' FROM #__phocadownload_categories AS a' . ' WHERE a.id = ' . (int) $id; $db->setQuery($query); $item = $db->loadObject(); if (isset($item->id) && isset($item->slug)) { if ($text != '') { $textOutput = $text; } else { if (isset($item->title) && $item->title != '') { $textOutput = $item->title; } else { $textOutput = JText::_('PLG_CONTENT_PHOCADOWNLOAD_DOWNLOAD_CATEGORY'); } } $link = PhocaDownloadRoute::getCategoryRoute($item->id, $item->alias); //'index.php?option=com_phocadownload&view=category&id='.$item->slug.'&Itemid='. $itemId $output .= '<div class="phocadownloadcategory' . (int) $iSize . '"><a href="' . JRoute::_($link) . '" ' . $targetOutput . '>' . $textOutput . '</a></div>'; } } break; // - - - - - - - - - - - - - - - - // FILELIST // - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - // FILELIST // - - - - - - - - - - - - - - - - case 'filelist': $fileOrdering = PhocaDownloadOrdering::getOrderingText($ordering); $query = 'SELECT a.id, a.title, a.alias, a.filename_play, a.filename_preview, a.link_external, a.image_filename, a.filename, c.id as catid, a.confirm_license, c.title as cattitle, c.alias as catalias,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as catslug' . ' FROM #__phocadownload AS a' . ' LEFT JOIN #__phocadownload_categories AS c ON a.catid = c.id'; if ((int) $id > 0) { $query .= ' WHERE c.id = ' . (int) $id; //$query .= ' WHERE c.id = '.(int)$id . ' AND a.published = 1 AND a.approved = 1'; } else { //$query .= ' WHERE a.published = 1 AND a.approved = 1'; } $query .= ' ORDER BY a.' . $fileOrdering; $query .= ' LIMIT 0, ' . (int) $limit; $db->setQuery($query); $items = $db->loadObjectList(); if (!empty($items)) { $output .= '<div class="phocadownloadfilelist">'; foreach ($items as $item) { $imageFileName = $l->getImageFileName($item->image_filename, $item->filename, 3, (int) $iSize); if (isset($item->id) && isset($item->slug) && isset($item->catid) && isset($item->catslug)) { if ($text != '') { $textOutput = $text; } else { if (isset($item->title) && $item->title != '') { $textOutput = $item->title; } else { $textOutput = JText::_('PLG_CONTENT_PHOCADOWNLOAD_DOWNLOAD_FILE'); } } if (isset($item->confirm_license) && $item->confirm_license > 0 || $fileView == 1) { $link = PhocaDownloadRoute::getFileRoute($item->id, $item->catid, $item->alias, $item->catalias, 0, 'file'); if ($iMime == 1) { $output .= '<div class="pd-filename phocadownloadfilelistitem phoca-dl-file-box-mod">' . $imageFileName['filenamethumb'] . '<div class="pd-document' . (int) $iSize . '" ' . $imageFileName['filenamestyle'] . '><a href="' . JRoute::_($link) . '" ' . $targetOutput . '>' . $textOutput . '</a></div></div>'; } else { $output .= '<div class="phocadownloadfilelist' . (int) $iSize . '"><a href="' . JRoute::_($link) . '" ' . $targetOutput . '>' . $textOutput . '</a></div>'; } } else { if ($item->link_external != '') { $link = $item->link_external; } else { $link = PhocaDownloadRoute::getFileRoute($item->id, $item->catid, $item->alias, $item->catalias, 0, 'download'); } if ($iMime == 1) { $output .= '<div class="pd-filename phocadownloadfilelistitem phoca-dl-file-box-mod">' . $imageFileName['filenamethumb'] . '<div class="pd-document' . (int) $iSize . '" ' . $imageFileName['filenamestyle'] . '><a href="' . JRoute::_($link) . '" ' . $targetOutput . '>' . $textOutput . '</a></div></div>'; } else { $output .= '<div class="phocadownloadfilelist' . (int) $iSize . '"><a href="' . JRoute::_($link) . '" ' . $targetOutput . '>' . $textOutput . '</a></div>'; } } } } $output .= '</div>'; } break; // - - - - - - - - - - - - - - - - // FILE // - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - // FILE // - - - - - - - - - - - - - - - - case 'file': case 'fileplay': case 'fileplaylink': case 'filepreviewlink': if ((int) $id > 0) { $query = 'SELECT a.id, a.title, a.alias, a.filename_play, a.filename_preview, a.link_external, a.image_filename, a.filename, c.id as catid, a.confirm_license, c.title as cattitle, c.alias as catalias,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as catslug' . ' FROM #__phocadownload AS a' . ' LEFT JOIN #__phocadownload_categories AS c ON a.catid = c.id' . ' WHERE a.id = ' . (int) $id; $db->setQuery($query); $item = $db->loadObject(); if (isset($item->id) && isset($item->slug) && isset($item->catid) && isset($item->catslug)) { if ($text != '') { $textOutput = $text; } else { if (isset($item->title) && $item->title != '') { $textOutput = $item->title; } else { if ($view == 'fileplay') { $textOutput = JText::_('PLG_CONTENT_PHOCADOWNLOAD_PLAY_FILE'); } else { $textOutput = JText::_('PLG_CONTENT_PHOCADOWNLOAD_DOWNLOAD_FILE'); } } } $imageFileName = $l->getImageFileName($item->image_filename, $item->filename, 3, (int) $iSize); // - - - - - // PLAY // - - - - - if ($view == 'fileplay') { $play = 1; $fileExt = ''; $filePath = PhocaDownloadPath::getPathSet('fileplay'); $filePath = str_replace('../', JURI::base(true) . '/', $filePath['orig_rel_ds']); if (isset($item->filename_play) && $item->filename_play != '') { $fileExt = PhocaDownloadFile::getExtension($item->filename_play); $canPlay = PhocaDownloadFile::canPlay($item->filename_play); if ($canPlay) { $tmpl['playfilewithpath'] = $filePath . $item->filename_play; $tmpl['playerpath'] = JURI::base() . 'components/com_phocadownload/assets/flowplayer/'; } else { $output .= JText::_('PLG_CONTENT_PHOCADOWNLOAD_NO_CORRECT_FILE_FOR_PLAYING_FOUND'); $play = 0; } } else { $output .= JText::_('PLG_CONTENT_PHOCADOWNLOAD_NO_FILE_FOR_PLAYING_FOUND'); $play = 0; } if ($play == 1) { //Correct MP3 $tmpl['filetype'] = ''; if ($fileExt == 'mp3') { $tmpl['filetype'] = 'mp3'; $playerheight = $playerheightmp3; } $versionFLP = '3.2.2'; $versionFLPJS = '3.2.2'; //Flow Player $document->addScript($tmpl['playerpath'] . 'flowplayer-' . $versionFLPJS . '.min.js'); $output .= '<div style="text-align:center;margin: 10px auto">' . "\n" . '<div style="margin: 0 auto;text-align:center; width:' . $playerwidth . 'px"><a href="' . $tmpl['playfilewithpath'] . '" style="display:block;width:' . $playerwidth . 'px;height:' . $playerheight . 'px" id="pdplayer' . $i . '"></a>' . "\n"; if ($tmpl['filetype'] == 'mp3') { $output .= '<script type="text/javascript">' . "\n" . 'window.addEvent("domready", function() {' . "\n" . 'flowplayer("pdplayer' . $i . '", "' . $tmpl['playerpath'] . 'flowplayer-' . $versionFLP . '.swf",' . '{ ' . "\n" . ' clip: { ' . "\n" . ' url: \'' . $tmpl['playfilewithpath'] . '\',' . "\n" . ' autoPlay: false' . "\n" . ' }, ' . "\n" . ' plugins: { ' . "\n" . ' controls: { ' . "\n" . ' fullscreen: false, ' . "\n" . ' height: ' . $playerheight . "\n" . ' } ' . "\n" . ' } ' . "\n" . '} ' . "\n" . ');' . "\n" . '});' . '</script>' . "\n"; } else { $output .= '<script type="text/javascript">' . "\n" . 'window.addEvent("domready", function() {' . "\n" . 'flowplayer("pdplayer' . $i . '", "' . $tmpl['playerpath'] . 'flowplayer-' . $versionFLP . '.swf",' . "\n" . '{ ' . "\n" . ' clip: { ' . "\n" . ' url: \'' . $tmpl['playfilewithpath'] . '\',' . "\n" . ' autoPlay: false,' . "\n" . ' autoBuffering: true' . "\n" . ' }, ' . "\n" . '} ' . "\n" . ');' . "\n" . '});' . '</script>' . "\n"; } $output .= '</div></div>' . "\n"; } } else { if ($view == 'fileplaylink') { // PLAY - - - - - - - - - - - - $windowWidthPl = (int) $playerwidth + 30; $windowHeightPl = (int) $playerheight + 30; $windowHeightPlMP3 = (int) $playerheightmp3 + 30; //$playWindow = $paramsC->get( 'play_popup_window', 0 ); if ($playWindow == 1) { $buttonPl = new JObject(); $buttonPl->set('methodname', 'js-button'); $buttonPl->set('options', "window.open(this.href,'win2','width=" . $windowWidthPl . ",height=" . $windowHeightPl . ",scrollbars=yes,menubar=no,resizable=yes'); return false;"); $buttonPl->set('optionsmp3', "window.open(this.href,'win2','width=" . $windowWidthPl . ",height=" . $windowHeightPlMP3 . ",scrollbars=yes,menubar=no,resizable=yes'); return false;"); } else { JHTML::_('behavior.modal', 'a.modal-button'); $document->addCustomTag("<style type=\"text/css\"> \n" . " #sbox-window.phocadownloadplaywindow {background-color:#fff;padding:2px} \n" . " #sbox-overlay.phocadownloadplayoverlay {background-color:#000;} \n" . " </style> \n"); $buttonPl = new JObject(); $buttonPl->set('name', 'image'); $buttonPl->set('modal', true); $buttonPl->set('methodname', 'modal-button'); $buttonPl->set('options', "{handler: 'iframe', size: {x: " . $windowWidthPl . ", y: " . $windowHeightPl . "}, overlayOpacity: 0.7, classWindow: 'phocadownloadplaywindow', classOverlay: 'phocadownloadplayoverlay'}"); $buttonPl->set('optionsmp3', "{handler: 'iframe', size: {x: " . $windowWidthPl . ", y: " . $windowHeightPlMP3 . "}, overlayOpacity: 0.7, classWindow: 'phocadownloadplaywindow', classOverlay: 'phocadownloadplayoverlay'}"); } // - - - - - - - - - - - - - - - $fileExt = ''; $filePath = PhocaDownloadPath::getPathSet('fileplay'); $filePath = str_replace('../', JURI::base(true) . '/', $filePath['orig_rel_ds']); if (isset($item->filename_play) && $item->filename_play != '') { $fileExt = PhocaDownloadFile::getExtension($item->filename_play); $canPlay = PhocaDownloadFile::canPlay($item->filename_play); if ($canPlay) { // Special height for music only $buttonPlOptions = $buttonPl->options; if ($fileExt == 'mp3') { $buttonPlOptions = $buttonPl->optionsmp3; } /*if ($text == '') { $text = JText::_('PLG_CONTENT_PHOCADOWNLOAD_PLAY'); }*/ if ($text != '') { $textOutput = $text; //} else if (isset($item->title) && $item->title != '') { // $textOutput = $item->title; } else { $textOutput = JText::_('PLG_CONTENT_PHOCADOWNLOAD_PLAY'); } $playLink = JRoute::_(PhocaDownloadRoute::getFileRoute($item->id, $item->catid, $item->alias, $item->catalias, 0, 'play')); if ($iMime == 1) { $output .= '<div class="pd-filename phocadownloadfile phoca-dl-file-box-mod">' . $imageFileName['filenamethumb'] . '<div class="pd-document' . (int) $iSize . '" ' . $imageFileName['filenamestyle'] . '>'; } else { $output .= '<div><div class="phocadownloadplay' . (int) $iSize . '">'; } if ($playWindow == 1) { $output .= '<a href="' . $playLink . '" onclick="' . $buttonPlOptions . '" >' . $textOutput . '</a>'; } else { $output .= '<a class="modal-button" href="' . $playLink . '" rel="' . $buttonPlOptions . '" >' . $textOutput . '</a>'; } $output .= '</div></div>'; } } else { $output .= JText::_('PLG_CONTENT_PHOCADOWNLOAD_NO_FILE_FOR_PLAYING_FOUND'); } } else { if ($view == 'filepreviewlink') { if (isset($item->filename_preview) && $item->filename_preview != '') { $fileExt = PhocaDownloadFile::getExtension($item->filename_preview); if ($fileExt == 'pdf' || $fileExt == 'jpeg' || $fileExt == 'jpg' || $fileExt == 'png' || $fileExt == 'gif') { $filePath = PhocaDownloadPath::getPathSet('filepreview'); $filePath = str_replace('../', JURI::base(true) . '/', $filePath['orig_rel_ds']); $previewLink = $filePath . $item->filename_preview; //$previewWindow = $paramsC->get( 'preview_popup_window', 0 ); // PREVIEW - - - - - - - - - - - - $windowWidthPr = (int) $previewwidth + 20; $windowHeightPr = (int) $previewheight + 20; if ($previewWindow == 1) { $buttonPr = new JObject(); $buttonPr->set('methodname', 'js-button'); $buttonPr->set('options', "window.open(this.href,'win2','width=" . $windowWidthPr . ",height=" . $windowHeightPr . ",scrollbars=yes,menubar=no,resizable=yes'); return false;"); } else { JHTML::_('behavior.modal', 'a.modal-button'); $document->addCustomTag("<style type=\"text/css\"> \n" . " #sbox-window.phocadownloadpreviewwindow {background-color:#fff;padding:2px} \n" . " #sbox-overlay.phocadownloadpreviewoverlay {background-color:#000;} \n" . " </style> \n"); $buttonPr = new JObject(); $buttonPr->set('name', 'image'); $buttonPr->set('modal', true); $buttonPr->set('methodname', 'modal-button'); $buttonPr->set('options', "{handler: 'iframe', size: {x: " . $windowWidthPr . ", y: " . $windowHeightPr . "}, overlayOpacity: 0.7, classWindow: 'phocadownloadpreviewwindow', classOverlay: 'phocadownloadpreviewoverlay'}"); $buttonPr->set('optionsimg', "{handler: 'image', size: {x: 200, y: 150}, overlayOpacity: 0.7, classWindow: 'phocadownloadpreviewwindow', classOverlay: 'phocadownloadpreviewoverlay'}"); } // - - - - - - - - - - - - - - - /*if ($text == '') { $text = JText::_('PLG_CONTENT_PHOCADOWNLOAD_PREVIEW'); }*/ if ($text != '') { $textOutput = $text; //} else if (isset($item->title) && $item->title != '') { // $textOutput = $item->title; } else { $textOutput = JText::_('PLG_CONTENT_PHOCADOWNLOAD_PREVIEW'); } if ($iMime == 1) { $output .= '<div class="pd-filename phocadownloadfile phoca-dl-file-box-mod">' . $imageFileName['filenamethumb'] . '<div class="pd-document' . (int) $iSize . '" ' . $imageFileName['filenamestyle'] . '>'; } else { $output .= '<div><div class="phocadownloadpreview' . (int) $iSize . '">'; } if ($previewWindow == 1) { $output .= '<a href="' . $previewLink . '" onclick="' . $buttonPr->options . '" >' . $text . '</a>'; } else { if ($fileExt == 'pdf') { // Iframe - modal $output .= '<a class="modal-button" href="' . $previewLink . '" rel="' . $buttonPr->options . '" >' . $textOutput . '</a>'; } else { // Image - modal $output .= '<a class="modal-button" href="' . $previewLink . '" rel="' . $buttonPr->optionsimg . '" >' . $textOutput . '</a>'; } } $output .= '</div></div>'; } } else { $output .= JText::_('PLG_CONTENT_PHOCADOWNLOAD_NO_FILE_FOR_PREVIEWING_FOUND'); } } else { if (isset($item->confirm_license) && $item->confirm_license > 0 || $fileView == 1) { $link = PhocaDownloadRoute::getFileRoute($item->id, $item->catid, $item->alias, $item->catalias, 0, 'file'); //'index.php?option=com_phocadownload&view=file&id='.$item->slug.'&Itemid='.$itemId if ($iMime == 1) { $output .= '<div class="pd-filename phocadownloadfile phoca-dl-file-box-mod">' . $imageFileName['filenamethumb'] . '<div class="pd-document' . (int) $iSize . '" ' . $imageFileName['filenamestyle'] . '><a href="' . JRoute::_($link) . '" ' . $targetOutput . '>' . $textOutput . '</a></div></div>'; } else { $output .= '<div class="phocadownloadfile' . (int) $iSize . '"><a href="' . JRoute::_($link) . '" ' . $targetOutput . '>' . $textOutput . '</a></div>'; } } else { if ($item->link_external != '') { $link = $item->link_external; } else { $link = PhocaDownloadRoute::getFileRoute($item->id, $item->catid, $item->alias, $item->catalias, 0, 'download'); } //$link = PhocaDownloadRoute::getCategoryRoute($item->catid,$item->catalias,$item->sectionid); //'index.php?option=com_phocadownload&view=category&id='. $item->catslug. '&download='. $item->slug. '&Itemid=' . $itemId if ($iMime == 1) { $output .= '<div class="pd-filename phocadownloadfile phoca-dl-file-box-mod">' . $imageFileName['filenamethumb'] . '<div class="pd-document' . (int) $iSize . '" ' . $imageFileName['filenamestyle'] . '><a href="' . JRoute::_($link) . '" ' . $targetOutput . '>' . $textOutput . '</a></div></div>'; } else { $output .= '<div class="phocadownloadfile' . (int) $iSize . '"><a href="' . JRoute::_($link) . '" ' . $targetOutput . '>' . $textOutput . '</a></div>'; } } } } } } } break; // - - - - - - - - - - - - - - - - // YOUTUBE // - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - // YOUTUBE // - - - - - - - - - - - - - - - - case 'youtube': if ($url != '' && PhocaDownloadUtils::isURLAddress($url)) { $l = new PhocaDownloadLayout(); $pdVideo = $l->displayVideo($url, 0, $youtubewidth, $youtubeheight); $output .= $pdVideo; } else { $output .= JText::_('PLG_CONTENT_PHOCADOWNLOAD_WRONG_YOUTUBE_URL'); } break; } $article->text = preg_replace($regex_all, $output, $article->text, 1); } } // end if count_matches return true; }
function _save($data, $filename, &$errSaveMsg, $fileExists = 0) { $user = JFactory::getUser(); $fileId = false; if ($fileExists == 1) { // We not only owerwrite the file but we must update it if (isset($filename) && $filename != '') { $db = JFactory::getDBO(); $query = 'SELECT a.id AS id' .' FROM #__phocadownload AS a' .' WHERE a.filename = '.$db->Quote($filename); $db->setQuery($query, 0, 1); $fileId = $db->loadObject(); if (!$db->query()) { $this->setError($db->getErrorMsg()); return false; } } } $row = $this->getTable('phocadownload'); if (isset($fileId->id) && (int)$fileId->id > 0) { $data['id'] = (int)$fileId->id; } $data['filesize'] = PhocaDownloadFile::getFileSize($filename, 0); $data['userid'] = $user->id; $data['author_email'] = $data['email']; $data['author_url'] = $data['website']; $data['token'] = PhocaDownloadUtils::getToken($data['title'].$filename); //$data['token'] = PhocaDownloadUtils::getToken($data['title'].$data['filename']); // Bind the form fields to the Phoca gallery table if (!$row->bind($data)) { $this->setError($this->_db->getErrorMsg()); return false; } // Create the timestamp for the date //$row->date = gmdate('Y-m-d H:i:s'); //$row->publish_up = gmdate('Y-m-d H:i:s'); //$jnow =JFactory::getDate(); /*$jnowU = $jnow->toUnix(); if (isset($jnowU)) { $jnowU = (int)$jnowU - 2; // to not display pending because of 1 second }*/ $unow = time(); $unow = $unow - 2;//Frontend will display pending if standard $jnow->toSql(); will be used $jnow = JFactory::getDate($unow);// the class JDate construct works with unix date $now = $jnow->toSql(); $row->date = $now; $row->publish_up = $now; //date('Y-m-d H:i:s', $jnowU); $row->publish_down = null; $row->filename = $filename; $row->catid = $data['catidfiles']; // Lang $userLang = PhocaDownloadUser::getUserLang(); $row->language = $userLang['lang']; // if new item, order last in appropriate group if (!$row->id) { $where = 'catid = ' . (int) $row->catid ; $row->ordering = $row->getNextOrder( $where ); } // Make sure the Phoca gallery table is valid if (!$row->check()) { $this->setError($this->_db->getErrorMsg()); return false; } // Store the Phoca gallery table to the database if (!$row->store()) { $this->setError($this->_db->getErrorMsg()); return false; } PhocaDownloadLog::log($row->id, 2); return true; }