'Video Title', 'value' => 'v.title' ), array( 'text' => 'Video Description', 'value' => 'v.description' ), array( 'text' => 'Channel Name', 'value' => 'c.name' ), array( 'text' => 'Channel Description', 'value' => 'c.description' ), array( 'text' => 'Video ID', 'value' => 'v.id' ), array( 'text' => 'Video Filename', 'value' => 'v.filename' ), ); public function getTags() { return array( PluginTags::$RECOMMENDED, PluginTags::$FREE ); } public function getDescription() { return "Finetune the layout and helpers"; } public function getName() { return "Layout"; } public function getPluginVersion() { return "1.1"; } public function getUUID() { return "layout84-8f5a-4d1b-b912-172c608bf9e3"; } public function getEmptyDataObject() { global $global; $obj = new stdClass(); /* $variablesFile = $global['systemRootPath'] . 'plugin/Customize/sass/variables.scss'; $subject = file_get_contents($variablesFile); $o = new stdClass(); $o->type = "textarea"; $o->value = $subject; $obj->colorsVariables = $o; $obj->showCustomCSS = true; * */ //$obj->showButtonNotification = false; $obj->showSearchOptionsBelowNavbar = false; $obj->categoriesTopButtons = false; $obj->categoriesTopButtonsShowOnlyOnFirstPage = true; $obj->categoriesTopButtonsShowVideosCount = false; $obj->categoriesTopButtonsFluid = true; $obj->categoriesTopLeftMenu = true; $obj->enableAccessibility = false; $obj->canToogleDarkAndLightMode = false; $o = new stdClass(); $o->type = array(0 => '-- ' . ("Random")) + self::getLoadersArray(); $o->value = 'avideo'; $obj->pageLoader = $o; return $obj; } static function getLoadersArray() { $files = Layout::getLoadersFiles(); $response = array(); foreach ($files as $key => $value) { $response[$value['name']] = ucfirst($value['name']); } return $response; } static function getLoadersFiles() { global $global; $files = _glob($global['systemRootPath'] . 'plugin/Layout/loaders/', '/.*html/'); $response = array(); foreach ($files as $key => $value) { $name = str_replace('.html', '', basename($value)); $response[$name] = array('path' => $value, 'name' => $name); } return $response; } static public function getLoader($file) { global $global; $files = self::getLoadersFiles(); $name = ''; if (!empty($file)) { foreach ($files as $key => $value) { if ($file == $value['name']) { $name = $value['name']; break; } } } if (empty($name)) { $rand_key = array_rand($files); $name = $files[$rand_key]['name']; } $content = file_get_contents($global['systemRootPath'] . 'plugin/Layout/loaders/' . $name . '.html'); return trim(preg_replace('/\s+/', ' ', str_replace('lds-', 'lds-' . uniqid(), $content))); } static function getLoaderDefault() { global $_getLoaderDefault; if (!isset($_getLoaderDefault)) { $obj = AVideoPlugin::getObjectData('Layout'); $loader = Layout::getLoader($obj->pageLoader->value); //$loader = Layout::getLoader('spinner'); $parts = explode('', $loader); if (preg_match('/style/', $parts[0])) { $parts[0] .= ''; } $_getLoaderDefault = array('css' => $parts[0], 'html' => $parts[1]); } return $_getLoaderDefault; } static function getBGAnimationFiles() { global $global; $files = _glob($global['systemRootPath'] . 'plugin/Layout/animatedBackGrounds/', '/.*php/'); $response = array(); foreach ($files as $key => $value) { $name = basename($value); if ($name === 'index.php') { continue; } $name = str_replace('.php', '', $name); $response[$name] = array('path' => $value, 'name' => $name); } return $response; } static function includeBGAnimationFile($file) { if (empty($file)) { return false; } $files = self::getBGAnimationFiles(); if ($file == 1) { $f = $files[array_rand($files)]; echo ''; include $f['path']; } foreach ($files as $key => $value) { if ($file == $value['name']) { include $value['path']; break; } } return true; } public function getPluginMenu() { global $global; return ""; $filename = $global['systemRootPath'] . 'plugin/Customize/pluginMenu.html'; return file_get_contents($filename); } public function getHeadCode() { global $global; $loaderParts = self::getLoaderDefault(); echo $loaderParts['css']; echo ""; return false; } static function getIconsList() { global $global; include $global['systemRootPath'] . 'plugin/Layout/fontAwesomeFAB.php'; // Fetch variables scss file in variable $font_vars = file_get_contents($global['systemRootPath'] . 'node_modules/fontawesome-free/scss/_variables.scss'); // Find the position of first $fa-var , as all icon class names start after that $pos = strpos($font_vars, '$fa-var'); // Filter the string and return only the icon class names $font_vars = substr($font_vars, $pos); // Create an array of lines $lines = explode("\n", $font_vars); $fonts_list = array(); foreach ($lines as $line) { // Discard any black line or anything without : if (strpos($line, ':') !== false) { // Icon names and their Unicode Private Use Area values are separated with : and hence, explode them. $t = explode(":", $line); // Remove the $fa-var with fa, to use as css class names. $className = str_replace('$fa-var-', '', $t[0]); if (!in_array($className, $font_awesome_brands)) { $classNameFull = "fa fa-{$className}"; } else { $classNameFull = "fab fa-{$className}"; } $fonts_list[$className] = array($className, $classNameFull, $t[1]); } } return $fonts_list; } static function getSelectSearchable($optionsArray, $name, $selected, $id = "", $class = "", $placeholder = false, $templatePlaceholder = '') { global $global, $nonCriticalCSS; if (empty($id)) { $id = $name; } $html = ""; if (empty($global['getSelectSearchable'])) { $html .= ''; $html .= ''; } if (empty($class)) { $class = "js-select-search"; } $html .= ''; // this is just to display something before load the select2 if (empty($templatePlaceholder)) { $html .= ''; } else { $html .= $templatePlaceholder; } $html .= ''; $global['getSelectSearchable'] = 1; return $html; } private static function getSearch2Code($id) { $code = ''; return $code; } static function getSelectSearchableHTML($optionsArray, $name, $selected, $id = "", $class = "", $placeholder = false, $templatePlaceholder = '') { global $global; if (empty($id)) { $id = $name; } $html = self::getSelectSearchable($optionsArray, $name, $selected, $id, $class, $placeholder, $templatePlaceholder); $html .= self::getSearch2Code($id); return $html; } static function getIconsSelect($name, $selected = "", $id = "", $class = "") { global $getIconsSelect; $getIconsSelect = 1; $icons = self::getIconsList(); if (empty($id)) { $id = uniqid(); } $html = self::getSearch2Code($id); self::addFooterCode($html); return self::getSelectSearchable($icons, $name, $selected, $id, $class . " iconSelect", true); } static function getAvailableFlags() { global $global; $flags = array(); include_once $global['systemRootPath'] . 'objects/bcp47.php'; $files = _glob("{$global['systemRootPath']}locale", '/^[a-z]{2}(_.*)?.php$/'); foreach ($files as $filename) { $filename = basename($filename); $fileEx = basename($filename, ".php"); $name = $global['bcp47'][$fileEx]['label']; $flag = $global['bcp47'][$fileEx]['flag']; $flags[$fileEx] = array(json_encode(array('text' => $name, 'icon' => "flagstrap-icon flagstrap-{$flag}")), $fileEx, 'val3-' . $name); } return $flags; } static function getAllFlags() { global $global; if (empty($global)) { $global = []; } $flags = array(); include_once $global['systemRootPath'] . 'objects/bcp47.php'; /** * @var array $global */ foreach ($global['bcp47'] as $key => $filename) { $name = $filename['label']; $flag = $filename['flag']; $flags[$key] = array(json_encode(array('text' => $name, 'icon' => "flagstrap-icon flagstrap-{$flag}")), $key, 'val3-' . $name); } return $flags; } static function getLangsSelect($name, $selected = "", $id = "", $class = "navbar-btn", $flagsOnly = false, $getAll = false) { global $getLangsSelect, $sortedFlagsCache; $getLangsSelect = 1; // Determine whether to get all flags or available flags if ($getAll) { $flags = self::getAllFlags(); } else { $flags = self::getAvailableFlags(); } // Cache sorted flags to avoid repeated sorting on each request if (!isset($sortedFlagsCache)) { // Sort flags alphabetically based on the 'text' field uasort($flags, function ($a, $b) { $infoA = json_decode($a[0]); $infoB = json_decode($b[0]); return strcmp($infoA->text, $infoB->text); // Compare language names alphabetically }); $sortedFlagsCache = $flags; // Cache the sorted flags } else { $flags = $sortedFlagsCache; // Use cached sorted flags } if (empty($id)) { $id = uniqid(); } if ($selected == 'us') { $selected = 'en_US'; } $selected = revertLangString($selected); // Determine the selected flag's icon (if available) if (!empty($flags[$selected])) { $selectedJson = json_decode($flags[$selected][0]); $selectedJsonIcon = $selectedJson->icon; } else { $selectedJsonIcon = ''; } // Build the HTML for the dropdown $html = '