function display($tpl = null) { global $mainframe; //Load pane behavior jimport('joomla.html.pane'); //initialise variables $editor =& JFactory::getEditor(); $document =& JFactory::getDocument(); $user =& JFactory::getUser(); $pane =& JPane::getInstance('sliders'); $c = jomtube_configs::get_instance(); $this->assignRef('c', $c); //get vars $cid = JRequest::getVar('cid'); //create the toolbar if ($cid) { JToolBarHelper::title(JText::_('EDIT VIDEO'), 'jomtube-videos'); } else { JToolBarHelper::title(JText::_('ADD VIDEO'), 'jomtube-videos'); } JToolBarHelper::apply(); JToolBarHelper::spacer(); JToolBarHelper::save(); JToolBarHelper::spacer(); JToolBarHelper::cancel(); //Get data from the model $model =& $this->getModel(); $row =& $this->get('Data'); if ($row->id != 0 && $row->video_type != 'local' && $row->video_type != null) { $r = new JApplication(); $r->redirect('index.php?option=com_jomtube&controller=videos&task=applylink&cid=' . $row->id); $ispublished = JHTML::_('select.genericlist', $yesno, 'published', '', 'value', 'text', $row->published == '' ? 1 : $row->published); $isdownloadable = JHTML::_('select.genericlist', $yesno, 'downloadable', '', 'value', 'text', $row->downloadable == '' ? 1 : $row->downloadable); $isfeatured = JHTML::_('select.genericlist', $yesno, 'featured', '', 'value', 'text', $row->featured); } $yesno[] = JHTML::_('select.option', 0, 'No'); $yesno[] = JHTML::_('select.option', 1, 'Yes'); //get video list in local directory if (JRequest::getVar('category_id', '') != '') { $row->directory =& $this->get('CatDirectory'); $selectedCat = JRequest::getVar('category_id', ''); } else { $selectedCat = $row->id ? $row->category_id : ''; } $currentdir = JPATH_SITE . (@$row->directory == '' ? '/jomtubefiles' : $row->directory); $dir = @opendir($currentdir); $videos = array(); while ($file = @readdir($dir)) { if ($file != "." and $file != "..") { $vidfile = $file; $thumbdir = "_thumbs"; $displaydir = "_display"; if ($vidfile != $thumbdir || $vidfile != $displaydir) { if (!is_dir($vidfile)) { $ext = JTHelper::getFileExt($vidfile); if (!$c->use_ffmpeg && $ext != 'flv') { continue; } $list_file[] = $vidfile; //JHTML::_('select.option', $vidfile); } } } //if } @closedir($dir); @sort($list_file); if (is_array($list_file)) { foreach ($list_file as $file) { $videos[] = JHTML::_('select.option', $file); } } $videolist = JHTML::_('select.genericlist', $videos, 'video_url', 'id="localvideolist" class="inputbox" style="width:326px;font-size:10px;" size="7" onchange="selectthisvideo()"', 'value', 'text', $row->id ? $row->video_url : ''); $this->assignRef('category_dir', $currentdir); $thumbdir = "_thumbs"; $current_dir = $currentdir . "/" . $thumbdir; $dir = @opendir($current_dir); $thumbs = array(); $thumb_file = array(); while ($file = @readdir($dir)) { if ($file != "." and $file != "..") { $thumbfile = $file; $thumb_file[] = $thumbfile; } } @closedir($dir); if (is_array($thumb_file)) { sort($thumb_file); foreach ($thumb_file as $file) { $thumbs[] = JHTML::_('select.option', $thumbfile, $file); } } //****************************************** $thumblist = JHTML::_('select.genericlist', $thumbs, 'video_thumb', 'id="localthumblist" class="inputbox" style="width:326px; font-size:10px;" size="7" onchange="selectthisthumb()"', 'value', 'text', $row->id ? $row->video_thumb : ''); //get parent option $categories =& $this->get('ParentOption'); $parentOptions[] = JHTML::_('select.option', '', '-Select Parent-'); foreach ($categories as $category) { $category_name = str_repeat(' ', 4 * substr_count($category->family_id, "/")) . "+" . $category->category_name; $parentOptions[] = JHTML::_('select.option', $category->id, $category_name); } $parentSelect = JHTML::_('select.genericlist', $parentOptions, 'category_id', 'id="catid" class="inputbox" size="1" onchange="selectCategory()"', 'value', 'text', $selectedCat); //clean data JFilterOutput::objectHTMLSafe($row, ENT_QUOTES, 'catdescription'); //assign data to template $this->assignRef('row', $row); $this->assignRef('editor', $editor); $this->assignRef('parentSelect', $parentSelect); $this->assignRef('pane', $pane); $this->assignRef('ispublished', $ispublished); $this->assignRef('isdownloadable', $isdownloadable); $this->assignRef('isfeatured', $isfeatured); $this->assignRef('localvideolist', $videolist); $this->assignRef('localthumblist', $thumblist); //assign data to template $this->assignRef('lists', $lists); $this->assignRef('my', $my =& JFactory::getUser()); parent::display($tpl); }
function uploadbatch($data) { $db =& JFactory::getDBO(); $counter = 0; $upload_batch_dir = JPATH_SITE . "/jomtubefiles/_batch_upload/"; $c = jomtube_configs::get_instance(); //get category directory $query = 'SELECT id, directory FROM #__jomtube_categories WHERE id = \'' . $_POST['category_id'] . '\''; $db->setQuery($query); $category = $db->loadObject(); $path_file = JPATH_SITE . $category->directory . '/'; $path_thumb = JPATH_SITE . $category->directory . '/_thumbs/'; $path_display = JPATH_SITE . $category->directory . '/_display/'; if (!is_dir($path_display)) { $oldumask = umask(0); @mkdir($path_display, 0755); umask($oldumask); } //get video from upload batch dir $dir = opendir($upload_batch_dir); $counter = 0; if ($category) { while ($file = readdir($dir)) { if ($file != "." and $file != "..") { $vidfile = $file; if (!is_dir($vidfile)) { //move file to the proper category directory if (copy($upload_batch_dir . $vidfile, $path_file . $vidfile)) { unlink($upload_batch_dir . $vidfile); //delete original file //Capitalize the first letter $video_title = str_replace('_', ' ', $vidfile); //remove extension of file $video_title = explode('.', $video_title); $video_title = $video_title[0]; $video_title = ucwords($video_title); $_POST['video_title'] = $_POST['video_desc'] = $video_title; $_POST['video_url'] = $vidfile; //get video duration if ($c->use_php_ffmpeg) { //use php-ffmpeg $sec = JTHelper::getMovieDuration($path_file . $vidfile); $duration = JTHelper::sec2hms($sec); //covert to 00:00:00 i.e. hrs:min:sec*/ } else { //not use php-ffmpeg $sec = 6; $duration = ''; } //get the middle of the movie (time; 00:00:00 format) for thumbnail if ($c->use_ffmpeg) { //use ffmpeg $sec2 = $sec / 2; $sec2 = @round($sec2); if ($sec < 20) { $thumb_position = 5; } else { $thumb_position = JTHelper::sec2hms($sec2); } //convert video to flv or mp4 if ($c->h264_convert2mp4) { $path_new = $path_file . $vidfile . '.mp4'; JTHelper::movieToMp4H264_alduccino($path_file . $vidfile, $path_new, $c); //update video_url $_POST['video_url'] = $_POST['video_url'] . '.mp4'; } else { $path_new = $path_file . $vidfile . '.flv'; $ext = JTHelper::getFileExt($vidfile); if ($ext != 'flv') { JTHelper::movieToFlv($path_file . $vidfile, $path_new, $c); //update video_url $_POST['video_url'] = $_POST['video_url'] . '.flv'; } } $_POST['duration'] = $duration; //create thumb JTHelper::flvToThumbnail($path_file . $_POST['video_url'], $path_thumb . $_POST['video_url'] . '.jpg', 120, 90, $thumb_position, $c); //create display image JTHelper::flvToThumbnail($path_file . $_POST['video_url'], $path_display . $_POST['video_url'] . '.jpg', 470, 320, $thumb_position, $c); $_POST['video_thumb'] = $_POST['video_url'] . '.jpg'; $this->store($_POST, 1); $counter++; } else { // not use ffmpeg } } } } //if } closedir($dir); } //var_dump($counter); exit(); return $counter; }