text
stringlengths
2
104M
meta
dict
{% import '/core/spinner.twig' as spinner %} <div id="hidden-component-template-wrapper" class="hid"> {% if not yt.signin.isSignedIn %} <div id="shared-addto-watch-later-login" class="hid"> {{ yt.msgs.watchLaterSignIn|format('<a href="https://accounts.google.com/ServiceLogin?service=youtube&amp;uilel=3&amp;hl=en&amp;continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Fapp%3Ddesktop%26action_handle_signin%3Dtrue%26hl%3Den%26next%3D%252F%26feature%3Dsign_in_button&amp;passive=true">', '</a>')|raw }} </div> {% endif %} <div id="yt-uix-videoactionmenu-menu" class="yt-ui-menu-content"> <div class="hide-on-create-pl-panel"> <h3> {{ yt.msgs.addToHeader }} </h3> </div> <div class="add-to-widget"> {{ spinner.render(yt.msgs.addToLoading) }} </div> </div> </div>
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
{% macro render(data, class) %} {% from "/common/uix/button.twig" import render as button %} <span class="{{ class }} yt-uix-button-subscription-container {{ data.showSubscriptionPreferences ? "with-preferences" }}"> {%- if data.showUnsubConfirmDialog and data.unsubConfirmDialog -%} <span class="unsubscribe-confirmation-overlay-container"> <div class="yt-uix-overlay " data-overlay-style="primary" data-overlay-shape="tiny"> {% embed "/common/uix/dialog.twig" %} {% block dialog_content %} {% from "/common/uix/button.twig" import render as button %} <div class="unsubscribe-confirmation-overlay-content-container"> <div class="unsubscribe-confirmation-overlay-content"> <div class="unsubscribe-confirmation-message"> {{ rehike.getText(data.unsubConfirmDialog.dialogMessages.0) }} </div> </div> <div class="yt-uix-overlay-actions"> {{ button(data.unsubConfirmDialog.cancelButton.buttonRenderer) }} {{ button(data.unsubConfirmDialog.confirmButton.buttonRenderer) }} </div> </div> {% endblock %} {% endembed %} </div> </span> {% endif %} {% apply spaceless %} {{ button(data.subscriptionButton) }} {%- if data.showSubscriptionPreferences -%} {{ button(data.subscriptionPreferencesButton) }} {% endif %} {%- if data.subscriberCountRenderer -%} {{ _self.subscriber_count(data.subscriberCountRenderer) }} {% endif %} {% endapply %} {%- if data.showSubscriptionPreferences -%} <span class="subscription-preferences-overlay-container"> <div class="yt-uix-overlay " data-overlay-style="primary" data-overlay-shape="tiny"> {% embed "/common/uix/dialog.twig" %} {% import "/core/spinner.twig" as spinner %} {% block dialog_content %} <div class="subscription-preferences-overlay-content-container"> <div class="subscription-preferences-overlay-loading "> {{ spinner.render(yt.msgs.loading) }} </div> <div class="subscription-preferences-overlay-content"></div> </div> {% endblock %} {% endembed %} </div> </span> {% endif %} </span> {% endmacro %} {%- macro subscriber_count(data) -%} <span class="yt-subscription-button-subscriber-count-{{ data.branded ? "branded" : "unbranded" }}-{{ data.direction }} yt-subscriber-count" title="{{ data.simpleText }}" aria-label="{{ data.simpleText }}" tabindex="0" > {{ data.simpleText }} </span> {%- endmacro -%}
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
{# # Lockup V2 # A replacement for absolutely abhorrent Lockup V1. # # @author Aubrey Pankow <[email protected]> #} {% macro main(data, style, thumbX, thumbY, config) %} {% from "common/uix/lockup/thumb.twig" import render as thumb %} {% from "common/uix/badge_list.twig" import render as badge_list %} {% from "common/uix/subscription_button.twig" import render as subscription_button %} {% from "common/uix/button.twig" import render as button %} {% if data.info %} {% set info = data.info %} {% if data.type == "channel" %} {% set thumbX = thumbY %} {% endif %} <{{ config.type ?? "div" }} class="yt-lockup yt-lockup-{{ style }} yt-lockup-{{ data.type }} clearfix {% for class in config.class %}{{ class ~ " " }}{% endfor %}"> <div class="yt-lockup-dismissible {{ style == "tile" ? "yt-uix-tile" }}"> {%- if data.type == "channel" -%} {{ thumb(data, thumbY, thumbY) }} {%- elseif data.type == "movie" -%} {{ thumb(data, thumbX, (thumbX * 1.43)|round) }} {%- else -%} {{ thumb(data, thumbX, thumbY) }} {%- endif -%} <div class="yt-lockup-content"> {% if info.topStandaloneBadge %} <span class="yt-badge standalone-collection-badge-renderer-icon"> {{ info.topStandaloneBadge.metadataBadgeRenderer.label }} </span> {% endif %} <h3 class="yt-lockup-title {{ info.menu ? "contains-action-menu" }}"> <a href="{{ rehike.getUrl(info) }}" class="spf-link yt-uix-tile-link yt-ui-ellipsis yt-ui-ellipsis-2" title="{{ rehike.getText(info.title) }}"> {{ rehike.getText(info.title) }} {% if data.type == "channel" and info.ownerBadges %} <span title="{{ yt.msgs.verified }}" class="yt-uix-tooltip yt-channel-title-icon-verified yt-sprite"></span> {% endif %} </a> {%- if getVideoTime(info) != null -%} {{ _self.a11yDesc(getVideoTime(info)) }} {% endif %} </h3> {% if getByline(info) != null and data.type != "channel" %} {% set byline = getByline(info) %} <div class="yt-lockup-byline"> {% set bylineUrl = rehike.getUrl(byline.runs[0]) %} {% if bylineUrl %} {{ rehike.config.appearance.usernamePrepends ? yt.msgs.usernamePrepend }} <a href="{{ bylineUrl }}" class="spf-link">{{ rehike.getText(byline) }}</a> {% if info.ownerBadges %} <span title="{{ yt.msgs.verified }}" class="yt-uix-tooltip yt-channel-title-icon-verified yt-sprite"></span> {% endif %} {% else %} {# If there is no byline URL, then it's probably something else (like mixes byline) #} {{ rehike.getText(byline) }} {% endif %} </div> {% endif %} {% if data.type == "playlist" or data.type == "radio" %} {{ _self.playlistMeta(data, style) }} {% elseif getMeta(info) != false %} <div class="yt-lockup-meta"> <ul class="yt-lockup-meta-info"> {% for meta in getMeta(info) %} <li>{{ rehike.getText(meta) }}</li> {% endfor %} {% if info.upcomingEventData %} {# hitchhiker localized date hack #} <li> {%- for run in info.upcomingEventData.upcomingEventText.runs -%} {%- if run.text == "DATE_PLACEHOLDER" -%} <span class="localized-date" data-timestamp="{{ info.upcomingEventData.startTime }}" data-format="longdateonly"></span> {%- else -%} {{ run.text }} {%- endif -%} {%- endfor -%} </li> {% endif %} </ul> </div> {{ data.type == "channel" and style == "grid" ? subscription_button(info.subscribeButton) }} {% endif %} {% if style == "tile" and getDescSnippet(info) != false %} <div class="yt-lockup-description yt-ui-ellipsis yt-ui-ellipsis-2"> {{ rehike.getText(getDescSnippet(info))|nl2br }} </div> {% endif %} {%- if info.badges or info.upcomingEventData or (data.type == "channel" and style == "tile") -%} <div class="yt-lockup-badges"> {{ info.badges or info.upcomingEventData ? badge_list(info.badges, info.upcomingEventData) }} {{ data.type == "channel" and style == "tile" ? subscription_button(info.subscribeButton) }} </div> {%- endif -%} {%- if info.buttons -%} <div class="yt-lockup-meta"> {%- for btn in info.buttons -%} {%- if btn.toggleButtonRenderer -%} {%- set this = btn.toggleButtonRenderer -%} {%- if this.defaultServiceEndpoint.addUpcomingEventReminderEndpoint -%} <span class="yt-uix-livereminder"> {{ button({ style: "STYLE_DEFAULT", size: "SIZE_SMALL", icon: true, class: [ "yt-uix-livereminder-main-button" ], tooltip: this.defaultTooltip, text: this.isToggled ? this.toggledText : this.defaultText, attributes: { "uix-livereminder-video-id": info.videoId, "reminder-set-text": rehike.getText(this.toggledText), "href": "", "set-reminder-text": rehike.getText(this.defaultText) } }) }} </span> {%- endif -%} {%- endif -%} {%- endfor -%} </div> {%- endif -%} </div> </div> </{{ config.type ?? "div" }}> {% endif %} {% endmacro %} {% macro playlistMeta(data, style) %} {% set info = data.info %} {%- if style == "tile" -%} <ol class="yt-lockup-meta yt-lockup-playlist-items"> {% for video in info.videos %} {% if video.childVideoRenderer %} {% set this = video.childVideoRenderer %} <li class="yt-lockup-playlist-item clearfix"> <span class="yt-lockup-playlist-item-length">{{ getVideoTime(this) }}</span> <a href="{{ rehike.getUrl(this) }}" class="yt-lockup-playlist-item-title spf-link">{{ rehike.getText(this.title) }}</a> </li> {% endif %} {% endfor %} </ol> {%- endif -%} <div class="yt-lockup-meta"> <ul class="yt-lockup-meta-info"> <li> <a href="{{ info.viewPlaylistText.runs[0].navigationEndpoint ? rehike.getUrl(info.viewPlaylistText.runs[0]) : "/playlist?list=" ~ info.playlistId }}" class="spf-link">{{ info.viewPlaylistText ? rehike.getText(info.viewPlaylistText) : yt.msgs.viewFullPlaylist }}{% if data.type == "playlist" %} ({{ rehike.getText(info.videoCountText) }}){% endif %}</a> </li> </ul> </div> {% endmacro %} {% macro grid(data, thumbX = 196, thumbY = 110, config) %} {{ _self.main(getLockupInfo(data), "grid", thumbX, thumbY, config) }} {% endmacro %} {% macro tile(data, thumbX = 196, thumbY = 110, config) %} {{ _self.main(getLockupInfo(data), "tile", thumbX, thumbY, config) }} {% endmacro %} {# LEGACY #} {%- macro title(info, type, overflow = true, class) -%} <h3 class="yt-lockup-title "> <a href="{{ rehike.getUrl(info) }} " class=" {% if overflow %}yt-ui-ellipsis yt-ui-ellipsis-2{% endif %} {{ class ?: "" }} spf-link " title="{{ rehike.getText(info.title) }}" aria-describedby="description-id-{{ generateRid }}" dir="ltr"> {{ rehike.getText(info.title) }}{% if info.ownerBadges and type == "channel" %} <span title="{{ yt.msgs.verified }}" class="yt-uix-tooltip yt-channel-title-icon-verified yt-sprite"></span>{% endif %} </a> {%- if getVideoTime(info) != null -%} {{ _self.a11yDesc(getVideoTime(info)) }} {% endif %} </h3> {%- endmacro -%} {% macro a11yDesc(lengthText) %} <span class="accessible-description" id="description-id-{{ generateRid() }}"> {{ yt.msgs.durationA11y|format(lengthText) }} </span> {% endmacro %}
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
{% macro render(list, eventData) %} <ul class="yt-badge-list"> {% if eventData.startTime %} <li class="yt-badge-item"> <span class="yt-badge localized-date" data-timestamp="{{ eventData.startTime }}" data-format="weekdayshorttime"></span> </li> {% endif %} {% for item in list %} {% if item.metadataBadgeRenderer %} {% set this = item.metadataBadgeRenderer %} <li class="yt-badge-item"> <span class="yt-badge {{ this.style == "BADGE_STYLE_TYPE_LIVE_NOW" ? "yt-badge-live" }}">{{ this.label }}</span> </li> {% endif %} {% endfor %} </ul> {% endmacro %}
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
{%- macro render(data, styleOverride, id) -%} {%- if not data is empty -%} {% set wrapped = _self._buttonWrapper(data, styleOverride, id) %} {%- if data.clickcard and not data.manualClickcardWrapper -%} {% from "/common/uix/clickcard_wrapper.twig" import render as clickcard %} {{ clickcard(data.clickcard, wrapped) }} {%- elseif data.menu and not data.manualMenuWrapper -%} {% from "/common/uix/menu_wrapper.twig" import render as menu %} {{ menu(data.menu, wrapped) }} {%- elseif data.videoActionsMenu and not data.manualMenuWrapper -%} {% from "/common/uix/video_action_menu_wrapper.twig" import render as video_action_menu %} {{ video_action_menu(data.videoActionsMenu, wrapped) }} {%- else -%} {{ wrapped }} {%- endif -%} {%- endif -%} {%- endmacro -%} {%- macro _buttonWrapper(data, styleOverride, id) -%} {%- set hasUrl = rehike.getUrl(data) != "" -%} <{{ hasUrl ? "a" : "button" }} {% if data.href %} href="{{ data.href }}" {% elseif hasUrl %} href="{{ rehike.getUrl(data) }}" {% endif %} class="yt-uix-button yt-uix-button-size-{{ resolveSize(data.size) }} {% if not data.noStyle %}yt-uix-button-{{ styleOverride ?? resolveStyle(data.style) }}{% endif %} {% if data.text.runs is empty and not data.text.simpleText and not data.thumb %} yt-uix-button-empty {% endif %} {% if data.icon %} yt-uix-button-has-icon {% if not data.icon.iconType or data.icon.noIconMarkupOverride %} no-icon-markup {% endif %} {% endif %} {% if hasUrl %} spf-link {% endif %} {% if data.menu %} yt-uix-menu-trigger {% elseif data.clickcard %} yt-uix-clickcard-target {% endif %} {% if data.spf %} spf-link {% endif %} {# Render custom classes #} {% for class in data.class %} {{ class ~ " " }} {% endfor %} {% if data.tooltip %} yt-uix-tooltip {% endif %}" type="{{ data.type ?? "button" }}" {% if data.onclick %} onclick="{{ data.onclick }}" {% elseif data.href %} onclick=";window.location.href=this.getAttribute('href');return false;" {% elseif not hasUrl %} onclick=";return false;" {% endif %} {% if data.tooltip %} title="{{ data.tooltip }}" {% endif %} {% for name, value in obj2arr(data.accessibility.accessibilityData) %} aria-{{ name }}="{{ value }}" {% endfor %} {% if id or data.targetId %} id="{{ id ?? data.targetId }}" {% endif %} {% for name, value in data.customAttributes %} {{ name }}="{{ value }}" {% endfor %} {% if data.role %} role="{{ data.role }}" {% endif %} {% for name, value in data.attributes %} data-{{ name }}="{{ value }}" {% endfor %} {% if data.accessibilityLabel %} aria-label="{{ data.accessibilityLabel }}" {% endif %} {% if data.isDisabled %} disabled="" {% endif %} > {%- if data.icon.iconType -%} <span class="yt-uix-button-icon-wrapper"> <span class="yt-uix-button-icon yt-uix-button-icon-{{ const2class(data.icon.iconType) }} yt-sprite"></span> </span> {%- endif -%} {%- apply spaceless -%} {{ (data.text and not data.text is empty) or data.thumb ? _self._buttonContent(data) }} {%- endapply -%} </{{ hasUrl ? "a" : "button" }}> {%- endmacro -%} {%- macro _buttonContent(data) -%} {%- from "common/thumb.twig" import render as thumb -%} {%- apply spaceless -%} <span class="yt-uix-button-content"> {%- endapply -%} {%- if data.thumb -%} {{ thumb(data.thumb) }} {%- endif -%} {%- if data.text.simpleText -%} {{ data.text.simpleText }} {%- else -%} {%- for run in data.text.runs -%} {%- if not run.class and not run.accessibilityLabel -%} {{ run.text }} {%- else -%} <span {% if run.class %}class="{{ run.class }}"{% endif %}{% if run.accessibilityLabel %} aria-label="{{ run.accessibilityLabel }}"{% endif %}> {{ run.text }} </span> {%- endif -%} {%- endfor -%} {%- endif -%} {%- if data.hasArrow -%} <span class="yt-uix-button-arrow yt-sprite"></span> {%- endif -%} {%- apply spaceless -%} </span> {%- endapply -%} {%- endmacro -%}
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
{% extends '/common/uix/dialog.twig' %} {% set id = 'feed-privacy-lb' %} {% block dialog_content %} <div id="feed-privacy-dialog"> </div> {% endblock %}
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
{% macro render(data, x = 196, y = 110) %} {% set info = data.info %} {% import "common/thumbnail_overlays.twig" as overlays %} {% from "core/html/img.twig" import img %} <div class="yt-lockup-thumbnail {{ data.type == "playlist" or data.type == "radio" ? "yt-pl-thumb" }} {{ getWLOverlay(info) != null ? "contains-addto" }}"> <a href="{{ rehike.getUrl(info) }}" class=" spf-link {{ data.type == "playlist" or data.type == "radio" ? "yt-pl-thumb-link" }}" aria-hidden="true"> <div class="yt-thumb video-thumb {{data.type == "video" and rehike.config.appearance.movingThumbnails ? "yt-uix-mouseover-img-wrap" }}"> <span class="yt-thumb-simple"> {{ img({ src: rehike.getThumb(data.thumbArray, y), width: x, height: y, ytImg: 1, delayLoad: true, onload: ";window.__ytRIL && __ytRIL(this)", customAttributes: { "data-mouseover-src": rehike.getThumb(info.richThumbnail.movingThumbnailRenderer.movingThumbnailDetails) } }) }} </span> </div> {% if data.type == "playlist" or data.type == "radio" %} {{ overlays.playlist(data, false) }} {% endif %} </a> {{ overlays.render(info.thumbnailOverlays, info.videoId) }} </div> {% endmacro %}
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
{% macro render(data) %} <form class="create-playlist-widget-form yt-uix-focustrap" method="POST" action="/playlist_ajax?action_create_playlist=1" data-max-title-length="150"> <input class="video-ids-input" type="hidden" name="video_ids"> <input class="source-playlist-id-input" type="hidden" name="source_playlist_id"> <div class="{{ not data.isCompact ? 'create-playlist-section' }}"> {% if not data.isCompact %} <label> <h2 class="yt-uix-form-label"> {{ data.label }} </h2> {{ _self.title_input() }} </label> {% else %} <div class="yt-uix-form-label" style="margin-top:0"> {{ _self.title_input() }} </div> {% endif %} </div> <div class="{{ not data.isCompact ? 'create-playlist-section create-playlist-bottom-section' }} clearfix"> <input class="privacy-value-input" type="hidden" name="p" value="public"> <div class="yt-uix-menu yt-uix-menu-sibling-content privacy-button-container"> <button class="yt-uix-button yt-uix-button-size-default yt-uix-button-{{ data.isCompact ? 'default' : 'text' }} yt-uix-button-has-icon no-icon-markup privacy-button yt-uix-menu-trigger" type="button" onclick=";return false;" aria-haspopup="true" role="button" aria-pressed="false" aria-label="{{ data.playlistPrivacyText }}" data-privacy-state="privacy-public"><span class="yt-uix-button-content">{{ data.publicText }}</span><span class="yt-uix-button-arrow yt-sprite"></span></button> <div class="yt-uix-menu-content yt-ui-menu-content yt-uix-menu-content-hidden" role="menu"> <ul class="create-playlist-widget-privacy-menu"> <li role="menuitem"> <button type="button" title="{{ data.publicText }}" class="yt-ui-menu-item has-icon yt-uix-menu-close-on-select yt-uix-button-has-icon no-icon-markup is-selected" data-value="public" data-privacy-state="privacy-public"> <span class="yt-ui-menu-item-label">{{ data.publicText }}</span> </button> </li> <li role="menuitem"> <button type="button" title="{{ data.unlistedText }}" class="yt-ui-menu-item has-icon yt-uix-menu-close-on-select yt-uix-button-has-icon no-icon-markup" data-value="unlisted" data-privacy-state="privacy-unlisted"> <span class="yt-ui-menu-item-label">{{ data.unlistedText }}</span> </button> </li> <li role="menuitem"> <button type="button" title="{{ data.privateText }}" class="yt-ui-menu-item has-icon yt-uix-menu-close-on-select yt-uix-button-has-icon no-icon-markup" data-value="private" data-privacy-state="privacy-private"> <span class="yt-ui-menu-item-label">{{ data.privateText }}</span> </button> </li> </ul> </div> </div> <div class="create-playlist-buttons"> {% if not data.isCompact %} <button class="yt-uix-button yt-uix-button-size-default yt-uix-button-default cancel-button" type="reset" onclick=";return true;"><span class="yt-uix-button-content">Cancel</span></button> {% endif %} <button class="yt-uix-button yt-uix-button-size-default yt-uix-button-primary create-button" type="submit" onclick=";return true;" disabled="True"><span class="yt-uix-button-content">Create</span></button> </div> </div> <div class="yt-uix-focustrap-trap" tabindex="0"></div> </form> {% endmacro %} {% macro title_input() %} <span class="title-input-container yt-uix-form-input-container yt-uix-form-input-text-container yt-uix-form-input-fluid-container"> <span class=" yt-uix-form-input-fluid"> <input class="yt-uix-form-input-text title-input" name="n" type="text" maxlength="150"> </span> </span> {% endmacro %}
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
{% macro render(data) %} <div class="addto-playlist-panel menu-panel active-panel"> <div class="addto-search-playlist-section" dir="ltr"> <span class="search-icon yt-sprite"></span> <input title="{{ data.searchText }}" aria-label="{{ data.searchText }}" type="text" class="addto-search-box yt-uix-form-input-text"> </div> <div class="playlists yt-uix-scroller" style="width:auto"> <ul class="addto-playlist-panel yt-uix-kbd-nav yt-uix-kbd-nav-list" role="menu" tabindex="0"> {% for list in data.playlists %} {% if list.playlistAddToOptionRenderer %} {{ _self.playlist_item(list.playlistAddToOptionRenderer) }} {% endif %} {% endfor %} </ul> </div> </div> <button class="create-playlist-item addto-menu-show-create-playlist-panel menu-panel active-panel"> {{ data.createNewText }} </button> <div class="addto-create-playlist-section create-playlist-panel menu-panel"> {% from "/common/addto/create_playlist.twig" import render as create_playlist %} {{ create_playlist(data.createPlaylistPanelRenderer) }} </div> {% endmacro %} {% macro playlist_item(data) %} {% set id = data.playlistId %} {% set title = rehike.getText(data.title) %} {% if data.privacy == "PUBLIC" %} {% set icon = "public-icon" %} {% elseif data.privacy == "UNLISTED" %} {% set icon = "unlisted-icon" %} {% elseif data.privacy == "PRIVATE" %} {% set icon = "private-icon" %} {% endif %} {% if data.containsSelectedVideos == "ALL" %} {% set status = "contains-all-selected-videos" %} {% elseif data.containsSelectedVideos == "SOME" %} {% set status = "contains-some-selected-videos" %} {% else %} {% set status = "" %} {% endif %} <li class="addto-playlist-item yt-uix-button-menu-item {{ status }}" data-full-list-id="{{ id }}" data-item-name="{{ title }}"> <button class="playlist-status" role="menuitemcheckbox" aria-checked="false"></button> <span class="playlist-name">{{ title }}</span> <span class="{{ icon }} yt-sprite"></span> </li> {% endmacro %}
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
{% macro notification_item(data) %} {% if data.notificationRenderer %} {% set this = data.notificationRenderer %} {% from "core/html/img.twig" import img %} {% import "common/uix/button.twig" as button %} <li> <div class="feed-item-container yt-lockup yt-lockup-tile yt-lockup-notification yt-uix-tile clearfix yt-uix-post-anchor yt-uix-post-anchor" data-post-action="/service_ajax?name=recordNotificationInteractionsEndpoint" data-post-data="{{ this.recordClickEndpoint.recordNotificationInteractionsEndpoint.serializedInteractionsRequest }}"> <div class="feed-item-dismissible"> <div class="notification-avatar"> {% if not this.read %}<div class="unread-dot"></div>{% endif %} <div class="yt-thumb video-thumb"> <span class="yt-thumb-simple"> {{ img({ src: rehike.getThumb(this.thumbnail, 40), width: 40, height: 40, onload: ";window.__ytRIL && __ytRIL(this)", ytImg: 1 }) }} </span> </div> </div> <div class="yt-lockup-content"> <h3 class="yt-lockup-title"> <a class="yt-uix-tile-link yt-ui-ellipsis yt-ui-ellipsis-6 spf-link " href="{{ this.navigationEndpoint.getCommentsFromInboxCommand ? "/watch?v=" ~ this.navigationEndpoint.getCommentsFromInboxCommand.videoId ~ "&lc=" ~ this.navigationEndpoint.getCommentsFromInboxCommand.linkedCommentId : rehike.getUrl(this) }}" title="{{ rehike.getText(this.shortMessage) }}">{{ rehike.getText(this.shortMessage) }}</a> <span class="accessible-description" id="description-id-{{ random(10000, 99999) }}"> - Notification</span> </h3> <ul class="yt-lockup-byline"> <li>{{ rehike.getText(this.sentTimeText) }}</li> </ul> </div> {% if this.videoThumbnail %} <div class="notification-thumb"> <div class="yt-thumb video-thumb"> <span class="yt-thumb-simple"> {{ img({ src: rehike.getThumb(this.videoThumbnail, 54), width: 72, height: 54, onload: ";window.__ytRIL && __ytRIL(this)", ytImg: 1 }) }} </span> </div> </div> {% endif %} </div> </div> </li> {% endif %} {% endmacro %}
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
{%- macro render(data) -%} {%- from "core/html/img.twig" import img -%} {%- if data.playlistVideoRenderer -%} {%- set this = data.playlistVideoRenderer -%} <tr class="pl-video yt-uix-tile" data-video-id="{{ this.videoId }}" data-set-video-id="" data-title="{{ rehike.getText(this.title) }}"> <td class="pl-video-handle"></td> <td class="pl-video-index"></td> <td class="pl-video-thumbnail"> <span class="pl-video-thumb ux-thumb-wrap contains-addto"> <a href="{{ rehike.getUrl(this) }}" class="spf-link" aria-hidden="true"> <span class="video-thumb yt-thumb yt-thumb-72"> <span class="yt-thumb-default"> <span class="yt-thumb-clip"> {{ img({ src: rehike.getThumb(this.thumbnail, 72), ytImg: true, onload: ";window.__ytRIL && __ytRIL(this)", delayLoad: true, width: 72 }) }} <span class="vertical-align"></span> </span> </span> </span> </a> {{ wlBtn.render(getWLOverlay(this), this.videoId) }} </span> </td> <td class="pl-video-title"> <a href="{{ rehike.getUrl(this) }}" class="pl-video-title-link yt-uix-tile-link spf-link">{{ rehike.getText(this.title) }}</a> <div class="pl-video-owner"> {% set byline = this.shortBylineText %} {{ rehike.config.appearance.usernamePrepends ? yt.msgs.usernamePrepend }} <a href="{{ rehike.getUrl(byline.runs[0]) }}" class="spf-link" data-ytid="{{ byline.navigationEndpoint.browseEndpoint.browseId }}" data-name="playlist">{{ rehike.getText(byline) }}</a> </div> <div class="pl-video-bottom-standalone-badge"></div> </td> <td class="pl-video-badges"></td> <td class="pl-video-added-by"></td> <td class="pl-video-time"> <div class="more-menu-wrapper"> <div class="timestamp"> <span aria-label="{{ this.lengthText.accessibility.accessibilityData.label }}">{{ rehike.getText(this.lengthText) }}</span> </div> <div class="pl-video-edit-options"></div> </div> </td> </tr> {%- endif -%} {%- endmacro -%}
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Footer; use Rehike\i18n; use Rehike\Model\Common\MButton; use Rehike\ConfigManager\ConfigManager; use Rehike\Player\Configurable; class MHelpButton extends MButton { public $targetId = "google-help"; public $class = [ "yt-uix-button-reverse", "yt-google-help-link", "inq-no-click" ]; public $attributes = [ "ghelp-tracking-param" => "", "ghelp-anchor" => "google-help", "load-chat-support" => "true", "feedback-product-id" => "59" ]; public function __construct() { $i18n = i18n::getNamespace("footer"); $this->text = (object) [ "simpleText" => $i18n->buttonHelp ]; $this->icon = (object) [ "iconType" => "QUESTIONMARK" ]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Footer; use Rehike\i18n; use Rehike\Model\Common\MButton; use Rehike\ConfigManager\ConfigManager; use Rehike\Player\Configurable; class MFooterLink { /** @var string */ public $simpleText; /** @var object */ public $navigationEndpoint; public function __construct($text, $url) { $this->simpleText = $text; $this->navigationEndpoint = (object) [ "commandMetadata" => (object) [ "webCommandMetadata" => (object) [ "url" => $url ] ] ]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Footer; use Rehike\i18n; use Rehike\Model\Common\MButton; use Rehike\ConfigManager\ConfigManager; use Rehike\Player\Configurable; class MFooter { /** @var string */ public $logoTooltip; /** @var MPickerButton[] */ public $pickers = []; /** @var MButton[] */ public $buttons = []; /** @var object[] */ public $primaryLinks = []; /** @var object[] */ public $secondaryLinks = []; /** @var string */ public $copyright; /** @var bool */ public $enableCopyright; public function __construct() { $i18n = i18n::newNamespace("footer"); $i18n->registerFromFolder("i18n/footer"); $rehikeVersion = (object) \Rehike\Version\VersionController::$versionInfo; $rehikeVersion->semanticVersion = \Rehike\Version\VersionController::getVersion(); $this->logoTooltip = $i18n->logoTooltip; $this->primaryLinks[] = new MFooterLink( $i18n->primaryAbout, "/yt/about/" ); $this->primaryLinks[] = new MFooterLink( $i18n->primaryPress, "/yt/press/" ); $this->primaryLinks[] = new MFooterLink( $i18n->primaryCopyright, "/yt/copyright/" ); $this->primaryLinks[] = new MFooterLink( $i18n->primaryCreators, "/yt/creators/" ); $this->primaryLinks[] = new MFooterLink( $i18n->primaryAdvertise, "/yt/advertise/" ); $this->primaryLinks[] = new MFooterLink( $i18n->primaryDevs, "/yt/dev/" ); if (ConfigManager::getConfigProp("appearance.showVersionInFooter")) $this->primaryLinks[] = new MFooterLink( $i18n->primaryVersion($rehikeVersion->semanticVersion, $rehikeVersion->branch), "/rehike/version" ); $this->secondaryLinks[] = new MFooterLink( $i18n->secondaryTerms, "/t/terms" ); $this->secondaryLinks[] = new MFooterLink( $i18n->secondaryPrivacy, "//www.google.com/intl/en/policies/privacy/" ); $this->secondaryLinks[] = new MFooterLink( $i18n->secondaryPolicySafety, "/yt/policyandsafety" ); $this->secondaryLinks[] = new MFooterLink( $i18n->secondaryFeedback, "//support.google.com/youtube/" ); $this->secondaryLinks[] = new MFooterLink( $i18n->secondaryTestTube, "/new" ); $this->copyright = $i18n->secondaryCopyright(date("Y")); $this->buttons[] = new MHistoryButton(); $this->buttons[] = new MHelpButton(); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Footer; use Rehike\i18n; use Rehike\Model\Common\MButton; use Rehike\ConfigManager\ConfigManager; use Rehike\Player\Configurable; class MHistoryButton extends MButton { public $class = [ "footer-history" ]; public function __construct() { $i18n = i18n::getNamespace("footer"); $this->icon = (object) [ "iconType" => "FOOTER_HISTORY" ]; $this->text = (object) [ "simpleText" => $i18n->buttonHistory ]; $this->navigationEndpoint = (object) [ "commandMetadata" => (object) [ "webCommandMetadata" => (object) [ "url" => "/feed/history" ] ] ]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Footer; use Rehike\i18n; use Rehike\Model\Common\MButton; use Rehike\ConfigManager\ConfigManager; use Rehike\Player\Configurable; class MPickerLanguageButton extends MButton { public $targetId = "yt-picker-language-button"; public $hasArrow = true; }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch; use Rehike\ConfigManager\ConfigManager; use Rehike\Signin\API as SignIn; use Rehike\Model\Watch\AgeGate\MPlayerAgeGate; /** * Implements all logic pertaining to the generation of watch * page data. * * This is fed into the templater just as a raw response would. * Please perform any processing within this scope. * * For most implementation, you should look at Watch8\Watch8Subcontroller.php * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Maintainers */ class WatchModel { static $useRyd; static $yt; static $response; static $rydData = null; static $subController = ""; static $isLive = false; static $isKidsVideo = false; static $isOwner = false; // Set with the primary info renderer static $title; // Shorthand data references static $results = null; static $secondaryResults = null; static $playlist = null; static $primaryInfo = null; static $secondaryInfo = null; static $commentSection = null; static $liveChat = null; static $engagementPanels = null; /** * Bake a watch page model * * This is the insertion point, so other operations are * performed within this function as well. * * @param object $yt (global state) * @param object $data from watch results response * @param object $rydData from RYD API response * @return object */ public static function bake(&$yt, $data, $videoId, $rydData = null) { // Initial logic self::$yt = &$yt; self::$response = &$data; self::$rydData = $rydData; self::$useRyd = self::shouldUseRyd(); self::destructureData($data->contents); self::$subController = self::getSubcontroller(); self::$engagementPanels = $data->engagementPanels ?? null; self::$isKidsVideo = self::getIsKidsVideo(self::$secondaryInfo); self::$isLive = self::getIsLive(self::$primaryInfo); self::$isOwner = self::getIsOwner(self::$secondaryInfo); // Get player error if ($error = @$yt->playerResponse->playabilityStatus->errorScreen->playerErrorMessageRenderer) { $yt->playerUnavailable = $error; if (!isset($yt->playerUnavailable->subreason)) { $yt->playerUnavailable->subreason = (object)[ "simpleText" => "Sorry about that." ]; } // If it's age restriction, show that if ("LOGIN_REQUIRED" == @$yt->playerResponse->playabilityStatus->status) { $yt->playerUnavailable = new MPlayerAgeGate(); } } // Model baking logic return (object) [ "isLive" => self::$isLive, "isOwner" => self::$isOwner, "results" => self::bakeResults($data, $videoId), "secondaryResults" => self::bakeSecondaryResults($data), "title" => self::$title, "playlist" => self::bakePlaylist(), "liveChat" => self::$liveChat ]; } /** * Get the watch subcontroller for a specific * watch variant. By default, this is watch8. */ public static function getSubcontroller() { return "Rehike\Model\Watch\Watch8\Watch8Subcontroller"; } /** * Parse the data provided by the bake function * and store global references within here. */ public static function destructureData(&$data) { self::$results = null; // Wrapped in isset to prevent crashes if (isset($data->twoColumnWatchNextResults->results->results)) { self::$results = &$data->twoColumnWatchNextResults->results->results; } self::$secondaryResults = null; if (isset($data->twoColumnWatchNextResults->secondaryResults->secondaryResults)) { self::$secondaryResults = &$data->twoColumnWatchNextResults->secondaryResults->secondaryResults; } if (isset($data->twoColumnWatchNextResults->conversationBar->liveChatRenderer)) { self::$liveChat = &$data->twoColumnWatchNextResults->conversationBar->liveChatRenderer; } // This one doesn't need to be isset wrapped for some reason self::$playlist = &$data->twoColumnWatchNextResults->playlist ?? null; // For sub-result references, iteration must be used if (isset(self::$results->contents)) for ($i = 0; $i < count(self::$results->contents); $i++) foreach (self::$results->contents[$i] as $name => &$value) switch ($name) { case "videoPrimaryInfoRenderer": self::$primaryInfo = &$value; break; case "videoSecondaryInfoRenderer": self::$secondaryInfo = &$value; break; case "itemSectionRenderer": // Determine based on section ID instead if (isset($value->sectionIdentifier)) switch ($value->sectionIdentifier) { case "comment-item-section": self::$commentSection = &$value; break; } break; } } /** * Determine whether or not to use the Return YouTube Dislike * API to return dislikes. Retrieved from application config. * * @return bool */ public static function shouldUseRyd() { return null != self::$rydData; } /** * Bake results * * Call gets passed to subcontroller for handling. * * @param object $data from watch results response * @return object */ public static function bakeResults(&$data, &$videoId) { return self::$subController::bakeResults($data, $videoId); } /** * Bake secondary results (recommendations) * * Call gets passed to subcontroller for handling. * * @param object $data from watch results response * @return object */ public static function bakeSecondaryResults(&$data) { return self::$subController::bakeSecondaryResults($data); } /** * Bake playlist * * Call gets passed to subcontroller for handling. */ public static function bakePlaylist(): ?object { return self::$subController::bakePlaylist(); } /** * Determine if a video is a kids video or not * * @param object $secondaryInfo * @return bool */ public static function getIsKidsVideo(&$secondaryInfo) { if (!isset($secondaryInfo->metadataRowContainer->rows)) return false; if ($rows = $secondaryInfo->metadataRowContainer) { foreach ($rows->metadataRowContainerRenderer->rows as $item) foreach ($item as $name => $contents) if ("richMetadataRowRenderer" == $name && "https://www.youtubekids.com" == $contents->contents[0]->richMetadataRenderer->endpoint->urlEndpoint->url ) { return true; } } return false; } /** * Determine if a video is live or not * * @param object $primaryInfo * @return bool */ public static function getIsLive(&$primaryInfo) { if (true == @$primaryInfo->viewCount->videoViewCountRenderer->isLive) { return true; } else { return false; } } public static function getIsOwner(&$secondaryInfo) { if (!SignIn::isSignedIn()) return false; if ($ucid = SignIn::getInfo()["ucid"]) { if ($ucid == @$secondaryInfo->owner->videoOwnerRenderer->navigationEndpoint->browseEndpoint->browseId) { return true; } else { return false; } } else { return false; } } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\Watch8; use Rehike\Model\Watch\WatchModel as WatchBase; use Rehike\Model\Watch\Watch7\MVideoDiscussionRenderer; use Rehike\Model\Watch\Watch7\MVideoDiscussionNotice; use Rehike\Model\Watch\Watch7\MCreatorBar; use Rehike\i18n; use Rehike\Util\PrefUtils; use Rehike\Signin\API as SignIn; use Rehike\Model\Browse\InnertubeBrowseConverter; use Rehike\Model\Common\MButton; use Rehike\Model\Traits\NavigationEndpoint; use Rehike\Model\Clickcard\MSigninClickcard; use function PHPSTORM_META\map; /** * Implements the watch8 subcontroller for the watch model * implementation. * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Maintainers */ class Watch8Subcontroller { /** * Called from the main watch model * * @param object $data * @return object[] */ public static function bakeResults(&$data, $videoId) { // Create references $primaryInfo = &WatchBase::$primaryInfo; $secondaryInfo = &WatchBase::$secondaryInfo; $commentSection = &WatchBase::$commentSection; $results = []; // Push creator bar if the video is yours if (WatchBase::$isOwner) { $results[] = (object) [ "videoCreatorBarRenderer" => new MCreatorBar($videoId) ]; } // Push primary info (if it exists) if (!is_null($primaryInfo)) $results[] = (object)[ "videoPrimaryInfoRenderer" => new MVideoPrimaryInfoRenderer(WatchBase::class, $videoId) ]; // Push secondary info (if it exists) if (!is_null($secondaryInfo)) $results[] = (object)[ "videoSecondaryInfoRenderer" => new MVideoSecondaryInfoRenderer(WatchBase::class) ]; // Push comments (if they exist) if (!is_null($commentSection)) { $content = @$commentSection->contents[0]; if (isset($content->continuationItemRenderer)) { // If the comment section exists, create a video // discussion renderer that contains its continuation. $continuationToken = $content->continuationItemRenderer ->continuationEndpoint->continuationCommand->token; // Push the continuation token to yt global WatchBase::$yt->commentsToken = $continuationToken; $results[] = (object)[ "videoDiscussionRenderer" => new MVideoDiscussionRenderer( $continuationToken ) ]; } else if (isset($content->messageRenderer)) { // If the comment section renderer contains a message, // create a videoDiscussionNotice instead. $message = $content->messageRenderer->text; $results[] = (object)[ "videoDiscussionNotice" => new MVideoDiscussionNotice($message) ]; } } return $results; } /** * Called from main watch model * * This performs check for autoplay and moves the video * to its respective position if so. * * @param object $data * @return object */ public static function bakeSecondaryResults(&$data) { $yt = &WatchBase::$yt; // Get data from the reference in the datahost $origResults = &WatchBase::$secondaryResults; $response = []; $i18n = i18n::getNamespace("watch"); if (isset($origResults->results)) { $secondaryResults = $origResults; /* * FIX (kirasicecreamm): Detection cannot rely purely upon assumption that the renderer * exists based on login status. It's required to perform a more sophisticated approach * when an item section renderer is not used to render the recommendations. * * Other than that, I made a silly mistake here and put this inside of the * autoplay condition below, which prevented it from displaying on playlists, as they * lack the autoplay condition. */ if (isset($secondaryResults->results[1]->itemSectionRenderer->contents)) { $recomsList = $secondaryResults->results[1]->itemSectionRenderer->contents; } else if (isset($secondaryResults->results)) { $recomsList = $secondaryResults->results; } else { return null; } InnertubeBrowseConverter::generalLockupConverter($recomsList); if (self::shouldUseAutoplay($data)) { if (is_countable($recomsList) && count($recomsList) > 0) { $autoplayIndex = self::getRecomAutoplay($recomsList); if (isset($_COOKIE["PREF"])) { $pref = PrefUtils::parse($_COOKIE["PREF"]); } else { $pref = (object) []; } // Move autoplay video to its own object $compactAutoplayRenderer = (object)[ "contents" => [ $recomsList[$autoplayIndex] ], "infoText" => $i18n->autoplayInfoText, "title" => $i18n->autoplayTitle, "toggleDesc" => $i18n->autoplayToggleDesc, "checked" => PrefUtils::autoplayEnabled($pref) ]; $response += ["compactAutoplayRenderer" => $compactAutoplayRenderer]; // Remove the original reference to prevent it from // rendering twice array_splice($recomsList, $autoplayIndex, 1); } } $response += ["results" => $recomsList]; return (object)$response; } return null; } /** * Called from main watch model * * This checks if the playlist is present and returns * the playlist data if so. */ public static function bakePlaylist(): ?object { $playlist = &WatchBase::$playlist; $i18n = i18n::getNamespace("watch"); // Return null if there is no playlist, this // makes the templater ignore it. $out = null; if (!is_null($playlist)) { $list = &$playlist->playlist; $out = $list; // Mostly Daylin's messy work // TODO: cleanup $countText = $list->videoCountText->runs ?? null; if (!is_null($countText)) { $curIndex = $countText[0]->text; $videoCount = $countText[2]->text; if ("1" == $videoCount) { $videoCount = $i18n->playlistVideosSingular; } else { $videoCount = $i18n->playlistVideosPlural($videoCount); } $out->videoCountText = (object) [ "currentIndex" => $curIndex, "videoCount" => $videoCount ]; } // "previous/next video ids also need a little work // let's just catch two cases with one" // Copied from Daylin's implementation again $playlistId = &WatchBase::$yt->playlistId; $out->isMix = substr($playlistId, 0, 2) == "RD"; $curIndexInt = &$list->localCurrentIndex; $prevIndexInt = $curIndexInt - 1; $nextIndexInt = $curIndexInt + 1; if ($prevIndexInt < 0) { $prevIndexInt = count($list->contents) - 1; } if ($nextIndexInt > count($list->contents) - 1) { $nextIndexInt = 0; } $prevIndexIntPlus = $prevIndexInt + 1; $nextIndexIntPlus = $nextIndexInt + 1; $prevId = $list->contents[$prevIndexInt] ->playlistPanelVideoRenderer->videoId ?? null ; $prevUrl = "/watch?v={$prevId}&index={$prevIndexIntPlus}&list={$playlistId}"; $nextId = $list->contents[$nextIndexInt] ->playlistPanelVideoRenderer->videoId ?? null ; $nextUrl = "/watch?v={$nextId}&index={$nextIndexIntPlus}&list={$playlistId}"; // Previous and next buttons // These are hidden, but the JS uses them, and there is also CSS // themes that unhide these buttons. $out->behaviorControls = []; $out->behaviorControls[] = new MButton([ "size" => "SIZE_DEFAULT", "style" => "STYLE_OPACITY", "tooltip" => $i18n->playlistPrevVideo, "navigationEndpoint" => NavigationEndpoint::createEndpoint($prevUrl), "icon" => (object) [ "iconType" => "WATCH_APPBAR_PLAY_PREV" ], "class" => [ "hid", "prev-playlist-list-item", "yt-uix-tooltip-masked", "yt-uix-button-player-controls" ] ]); $out->behaviorControls[] = new MButton([ "size" => "SIZE_DEFAULT", "style" => "STYLE_OPACITY", "tooltip" => $i18n->playlistNextVideo, "navigationEndpoint" => NavigationEndpoint::createEndpoint($nextUrl), "icon" => (object) [ "iconType" => "WATCH_APPBAR_PLAY_NEXT" ], "class" => [ "hid", "next-playlist-list-item", "yt-uix-tooltip-masked", "yt-uix-button-player-controls" ] ]); $isSaved = $out->menu->menuRenderer->items[0]->toggleMenuServiceItemRenderer->isToggled ?? false; $out->saveButton = new MButton([ "size" => "SIZE_DEFAULT", "style" => "STYLE_OPACITY", "id" => "gh-playlist-save", "icon" => (object) [], "class" => [ "yt-uix-button-player-controls", "yt-uix-playlistlike", "watch-playlist-like", $isSaved ? "yt-uix-button-toggled" : "" ], "tooltip" => $isSaved ? $i18n->playlistUnsave : $i18n->playlistSave, "attributes" => [ "like-label" => "", "playlist-id" => $out->playlistId, "unlike-label" => "", "unlike-tooltip" => $i18n->playlistUnsave, "like-tooltip" => $i18n->playlistSave, "toggle-class" => "yt-uix-button-toggled", "token" => "dummy" ] ]); if (!SignIn::isSignedIn()) { $out->saveButton->clickcard = new MSigninClickcard( $i18n->clickcardPlaylistSignIn, "", [ "text" => $i18n->clickcardSignIn, "href" => "https://accounts.google.com/ServiceLogin?continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Fnext%3D%252F%253Faction_handle_signin%3Dtrue%26feature%3D__FEATURE__%26hl%3Den%26app%3Ddesktop&passive=true&hl=en&uilel=3&service=youtube" ] ); } } return $out; } /** * Determine autoplay use status * * @return bool */ public static function shouldUseAutoplay(&$data) { /** * TODO: Specific master check to disable globally, * useful for building watch7/etc. later. */ // Disable if watch playlists available at all. if (is_null(WatchBase::$playlist)) { return true; } // If none of the conditions above are hit, always // return false as a catch all return false; } /** * Get autoplay recommendation * * @param object $results (index of the results) * @return int The index of the recommendation. */ public static function getRecomAutoplay(&$results) { for ($i = 0; $i < count($results); $i++) if (isset($results[$i]->compactVideoRenderer)) { return $i; } return 0; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\Watch8; use Rehike\Util\ExtractUtils; use Rehike\i18n; use Rehike\Model\Watch\Watch8\SecondaryInfo\MMetadataRowContainer; /** * Implement the model used by the video's secondary info renderer. * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Maintainers */ class MVideoSecondaryInfoRenderer { public $description; public $defaultExpanded; public $dateText; public $metadataRowContainer; public $showMoreText; public $showLessText; public function __construct($dataHost) { if (!is_null($dataHost::$secondaryInfo)) { $info = &$dataHost::$secondaryInfo; $primaryInfo = &$dataHost::$primaryInfo; // Legacy (COMPETENT) description if (isset($info->description)) { $this->description = $info->description; } // "Modern" (RETARDED) description elseif (isset($info->attributedDescription)) { $this->description = self::convertDescription($info->attributedDescription); } $this->defaultExpanded = $info->defaultExpanded ?? false; $this->dateText = isset($primaryInfo->dateText) ? ExtractUtils::resolveDate($primaryInfo->dateText) : null; $this->metadataRowContainer = new MMetadataRowContainer( $info->metadataRowContainer->metadataRowContainerRenderer->rows, $dataHost ); $this->showMoreText = $info->showMoreText ?? null; $this->showLessText = $info->showLessText ?? null; } } /** * Welp, the fucktards have done it again. The shitty description experiment is back, * and it's just as painful as it was before. Do they even have any fucking idea what * they're doing? The link color is fucking hardcoded blue for god's sake. There is * no fucking way they can be serious about this. They have to be fucking with us at * this point. What a bunch of fucking retards. * - Love, Aubrey <3 * * Anyways, this function just converts it back to the standard runs format. * * We use mb_substr with UTF-8 here, because the indices are set up for a JS environment. * * @param object $description videoSecondaryInfoRenderer.attributedDescription */ private static function convertDescription(object $description): object { // If there's no links if (!isset($description->commandRuns)) { return (object) [ "runs" => [ (object) [ "text" => $description->content ] ] ]; } $runs = []; // Start at the beginning of the string $start = 0; foreach ($description->commandRuns as $run) { // Text from before the link $beforeText = self::telegram_substr($description->content, $start, $run->startIndex - $start); if (!empty($beforeText)) { $runs[] = (object) [ "text" => $beforeText ]; } // Add the actual link $text = self::telegram_substr($description->content, $run->startIndex, $run->length); $endpoint = $run->onTap->innertubeCommand; $runs[] = (object) [ "text" => $text, "navigationEndpoint" => $endpoint ]; $start = $run->startIndex + $run->length; } // Add the text after the last link $lastText = self::telegram_substr($description->content, $start, null); if (!empty($lastText)) { $runs[] = (object) [ "text" => $lastText ]; } // Fix link text foreach ($runs as &$run) if (isset($run->navigationEndpoint)) { // Video links if (isset($run->navigationEndpoint->watchEndpoint) && !preg_match("/^([0-9]{1,2}(:)?)+$/", $run->text)) // Prevent replacing timestamps { $run->text = self::truncate("https://www.youtube.com" . $run->navigationEndpoint->commandMetadata->webCommandMetadata->url); } // Channel links elseif (isset($run->navigationEndpoint->browseEndpoint)) { switch (substr($run->navigationEndpoint->browseEndpoint->browseId, 0, 2)) { case "UC": $count = 1; // This has to be a variable for some reason $run->text = str_replace("\xc2\xa0", "", str_replace("/", "", $run->text, $count)); // Add @ if it isn't there if (substr($run->text, 0, 1) != "@") { $run->text = "@" . $run->text; } break; case "FE": break; default: $run->text = self::truncate("https://www.youtube.com" . $run->navigationEndpoint->commandMetadata->webCommandMetadata->url); break; } } // Weird fake channel links else if (str_contains($run->text, "\xc2\xa0")) { $run->text = self::truncate($run->navigationEndpoint->commandMetadata->webCommandMetadata->url); } } return (object) [ "runs" => $runs ]; } /** * Truncate link texts */ private static function truncate(?string $string): ?string { if (is_null($string)) return null; if (strlen($string) <= 37) { return $string; } else { return substr($string, 0, 37) . "..."; } } // FUCKING THANK YOU SO MUCH // THIS FIXED EMOJI PROBLEM // https://stackoverflow.com/a/66878985 private static function telegram_substr($str, $offset, $length) { $bmp = []; for( $i = 0; $i < mb_strlen($str); $i++ ) { $mb_substr = mb_substr($str, $i, 1); $mb_ord = mb_ord($mb_substr); $bmp[] = $mb_substr; if ($mb_ord > 0xFFFF) { $bmp[] = ""; } } return implode("", array_slice($bmp, $offset, $length)); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\Watch8; use Rehike\TemplateFunctions; use Rehike\ConfigManager\ConfigManager; use Rehike\Util\ExtractUtils; use Rehike\i18n; use Rehike\Model\Watch\Watch8\{ LikeButton\MLikeButtonRenderer, PrimaryInfo\MActionButton, PrimaryInfo\MOwner, PrimaryInfo\MSuperTitle }; use Rehike\Model\Watch\Watch8\PrimaryInfo\MPrivacyBadge; /** * Implement the model for the primary info renderer. * * This is generally a restructuring of the Kevlar formatted data * returned by InnerTube with WEB v2 as parameters. * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Maintainers */ class MVideoPrimaryInfoRenderer { /** @var string */ public $title = ""; /** @var string */ public $viewCount = ""; /** @var object[] */ public $superTitle; public MPrivacyBadge $privacyBadge; /** @var MOwner */ public $owner; /** @var MActionButton[] */ public $actionButtons = []; /** @var MLikeButtonRenderer */ public $likeButtonRenderer = []; // dataHost == get_called_class of caller public function __construct($dataHost, $videoId) { $info = &$dataHost::$primaryInfo ?? null; if (!is_null($info)) { $this->title = $info->title ?? null; // Also set title of the whole page from this property $dataHost::$title = TemplateFunctions::getText($this->title); if (isset($info->viewCount->videoViewCountRenderer)) $this->viewCount = (true === ConfigManager::getConfigProp("appearance.noViewsText")) ? ExtractUtils::isolateViewCnt(TemplateFunctions::getText($info->viewCount->videoViewCountRenderer->viewCount)) : TemplateFunctions::getText($info->viewCount->videoViewCountRenderer->viewCount) ?? null; $this->superTitle = isset($info->superTitleLink) ? new MSuperTitle($info->superTitleLink) : null; $this->likeButtonRenderer = new MLikeButtonRenderer($dataHost, $info->videoActions->menuRenderer, $videoId); $this->owner = new MOwner($dataHost); if (isset($info->badges)) foreach ($info->badges as $badge) { if ($icon = @$badge->metadataBadgeRenderer->icon->iconType) { if (str_starts_with($icon, "PRIVACY_")) { $this->privacyBadge = new MPrivacyBadge($icon); } } } // Create action butttons $orderedButtonQueue = []; /* * Updated to just hardcode this (it's generally fine, any video can be added to a playlist) * * To elaborate, the previous implementation iterated the available action buttons from * the InnerTube response, which usually worked. * * However, as of August 2022, YouTube has been experimenting with a rewrite of the action * buttons architecture, seemingly in an attempt to fix the Kevlar frontend watch page * imploding cuz they have 12 action buttons with full labels on the screen and typically * only report and sometimes transcript in the overflow menu. * * No, of course they didn't bother fixing this in the most intuitive ways, like having * hidden or dynamic label visibility (even though they always tell you what they are * if you hover over the buttons anyways so THERE IS NO FUCKING POINT TO THE ADDITIONAL * LABEL), instead they added a new type of button called "menuFlexibleItemRenderer" inside * a new container of "flexibleItems". * * It seems that, instead of the most obvious change of going from: * * 👍 12K 👎 DISLIKE ➡️ SHARE ⬇️ DOWNLOAD ❤️ THANKS ✂️ CLIP ➕ SAVE ... * * to: * * 👍 12K 👎 ➡️ ⬇️ ❤️ ✂️ ➕ ... * * or (they will never actually use the overflow menu tho): * * 👍 12K 👎 ➡️ ➕ ... * ┌───────────────┐ * │ 🚩 Report │ * │ 🗒️ Transcript │ * │ ⬇️ Download │ * │ ❤️ Thanks │ * │ ✂️ Clip │ * └───────────────┘ * * They instead decided to rework the API to "lazily" fix their broken ass frontend, * and this is why sometimes "add to" would randomly not render, because this experiment * only applies to ~1/10th of the unique visitor IDs. */ if (!$dataHost::$isKidsVideo) { $orderedButtonQueue[] = MActionButton::buildAddtoButton($videoId); } // Share button should always be built unless this is a // Kids video if (!$dataHost::$isKidsVideo) { $shareButton = MActionButton::buildShareButton(); if (null != $shareButton) $orderedButtonQueue[] = $shareButton; } // Report button shows as an action button for livestreams, rather than // residing in the overflow menu. if ($dataHost::$isLive) { $orderedButtonQueue[] = MActionButton::buildReportButton(); } else { $orderedButtonQueue[] = MActionButton::buildMoreButton(); } $this->actionButtons = &$orderedButtonQueue; } } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\Watch8\SecondaryInfo; use Rehike\Model\Traits\Runs; use Rehike\TemplateFunctions; use Rehike\i18n; class MMetadataRowContainer { use Runs; public $items = []; public function __construct(&$rows, $dataHost) { $i18n = i18n::getNamespace("watch"); // Configuration $addLicense = true; if (!is_null($rows)) { $this->items = $rows; foreach ($this->items as $index => $item) foreach ($item as $type => $data) { switch ($type) { case "metadataRowRenderer": $url = ""; if ($url = @$data->contents[0]->runs->navigationEndpoint->commandMetadata->webCommandMetadata->url && str_contains($url, "/t/creative_commons/")) $addLicense = false; break; case "richMetadataRowRenderer": // Very very icky, we don't want this. array_splice($this->items, $index, 1); $richItems = []; foreach ($data->contents as $row) { $row = $row->richMetadataRenderer ?? null; if (!is_null($row) && $row->style == "RICH_METADATA_RENDERER_STYLE_BOX_ART") { $richItems[] = (object) [ "richMetadataRowRenderer" => (object) [ "label" => (object) [ "simpleText" => $i18n->metadataGame ], "title" => $row->title, "subtitle" => $row->subtitle ?? null, "callToAction" => $row->callToAction ?? null, "navigationEndpoint" => $row->endpoint, "thumbnail" => $row->thumbnail ?? null ] ]; } } break; } } } /* * Also there is a new music renderer thing that is completely * batshit insane. * So enjoy this mess */ // Check if engagement panels exist. if (isset($dataHost::$engagementPanels)) // Go through the panels foreach ($dataHost::$engagementPanels as $panel) // Check the name of the current panel foreach ($panel->engagementPanelSectionListRenderer->content as $name => $content) if ("structuredDescriptionContentRenderer" == $name) // Go through the children of the panel and check the name of it foreach ($content->items as $item) foreach ($item as $name => $item) if ("videoDescriptionMusicSectionRenderer" == $name) { // And we're finally here. Now time for even more iteration. $musicItems = []; // Find the rows and go through them if (isset($item->carouselLockups)) // For some reason they don't exist on some videos. foreach (@$item->carouselLockups as $lockup) { // Add song title from the lockup if it exists if (isset($lockup->carouselLockupRenderer->videoLockup)) { $title = $i18n->metadataSong; $content = TemplateFunctions::getText($lockup->carouselLockupRenderer->videoLockup->compactVideoRenderer->title); $href = TemplateFunctions::getUrl($lockup->carouselLockupRenderer->videoLockup->compactVideoRenderer); if ("" == $href) $href = null; $musicItems[] = self::createSimpleField($title, $content, $href); } foreach (@$lockup->carouselLockupRenderer->infoRows as $row) { $data = @$row->infoRowRenderer; $element = isset($data->expandedMetadata) ? "expandedMetadata" : "defaultMetadata"; // WHY IS THE FUCKING TITLE HARDCODED UPPERCASE // I AM GOING TO FUCKING KILL MYSELF // love taniko $title = ucfirst(strtolower(TemplateFunctions::getText(@$data->title))); $content = TemplateFunctions::getText(@$data->{$element}); $href = TemplateFunctions::getUrl(@$data->{$element}->runs[0]); if ("" == $href) $href = null; $musicItems[] = self::createSimpleField($title, $content, $href); } } $this->items += $musicItems; } // If specified, add a license field for standard. if ($addLicense && !$dataHost::$isLive) array_unshift($this->items, self::getLicenseField()); // Add category option array_unshift($this->items, self::getCategoryField($dataHost)); // Add rich items (game in gaming video) if (isset($richItems) && count($richItems) > 0) foreach ($richItems as $item) array_unshift($this->items, $item); } protected function createSimpleField($title, $text, $href = null) { return (object)[ "metadataRowRenderer" => (object)[ "title" => (object)[ "runs" => [ self::createRun($title) ] ], "contents" => [ (object)[ "runs" => [ self::createRun($text, $href) ] ] ] ] ]; } protected function getCategoryField($dataHost) { $i18n = i18n::getNamespace("watch"); $title = $i18n->metadataCategory; $category = @$dataHost::$yt->playerResponse->microformat ->playerMicroformatRenderer->category ; if ($category) { return self::createSimpleField($title, $category); } } protected function getLicenseField() { $i18n = i18n::getNamespace("watch"); $title = $i18n -> metadataLicense; $text = $i18n -> metadataLicenseStandard; return self::createSimpleField($title, $text); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\Watch8\LikeButton; use Rehike\Model\Clickcard\MSigninClickcard; use Rehike\Signin\API as SignIn; use Rehike\i18n; /** * Define the like button. */ class MLikeButton extends MAbstractLikeButton { public function __construct($likeCount, $a11y, $isLiked, $videoId, $active = false) { $i18n = i18n::getNamespace("watch"); if ($active && is_numeric($likeCount)) $likeCount++; $this->accessibility = (object) [ "accessibilityData" => (object) [ "label" => $a11y ] ]; $this->tooltip = $i18n->actionLikeTooltip; if ($active) $this->tooltip = $i18n->actionLikeTooltipActive; $signinMessage = $i18n->likeClickcardHeading; $signinDetail = $i18n->voteClickcardTip; // Store a reference to the current sign in state. $signedIn = SignIn::isSignedIn(); if ($signedIn) { $this->attributes["post-action"] = "/service_ajax?name=likeEndpoint"; $this->class[] = "yt-uix-post-anchor"; } if (!$signedIn && !$active) { $this->clickcard = new MSigninClickcard($signinMessage, $signinDetail, [ "text" => $i18n->clickcardSignIn, "href" => "https://accounts.google.com/ServiceLogin?continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Fnext%3D%252F%253Faction_handle_signin%3Dtrue%26feature%3D__FEATURE__%26hl%3Den%26app%3Ddesktop&passive=true&hl=en&uilel=3&service=youtube" ]); } elseif ($signedIn && !$active) { $this->attributes["post-data"] = "action=like&id=" . $videoId; } elseif ($signedIn && $active) { $this->attributes["post-data"] = "action=removelike&id=" . $videoId; } parent::__construct("like-button", $active, $likeCount, $isLiked); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\Watch8\LikeButton; use Rehike\Model\Clickcard\MSigninClickcard; use Rehike\Signin\API as SignIn; use Rehike\i18n; /** * Define the dislike button. */ class MDislikeButton extends MAbstractLikeButton { public function __construct($dislikeCount, $a11y, $isDisliked, $videoId, $active = false) { $i18n = i18n::getNamespace("watch"); if ($active && is_numeric($dislikeCount)) $dislikeCount++; $this->accessibilityAttributes = [ "label" => $a11y ]; $this->tooltip = $i18n->actionDislikeTooltip; // TODO: i18n $signinMessage = $i18n->dislikeClickcardHeading; $signinDetail = $i18n->voteClickcardTip; // Store a reference to the current sign in state. $signedIn = SignIn::isSignedIn(); if ($signedIn) { $this->attributes["post-action"] = "/service_ajax?name=likeEndpoint"; $this->class[] = "yt-uix-post-anchor"; } if (!$signedIn && !$active) { $this->clickcard = new MSigninClickcard($signinMessage, $signinDetail, [ "text" => $i18n->clickcardSignIn, "href" => "https://accounts.google.com/ServiceLogin?continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Fnext%3D%252F%253Faction_handle_signin%3Dtrue%26feature%3D__FEATURE__%26hl%3Den%26app%3Ddesktop&passive=true&hl=en&uilel=3&service=youtube" ]); } elseif ($signedIn && !$active) { $this->attributes["post-data"] = "action=dislike&id=" . $videoId; } elseif ($signedIn && $active) { $this->attributes["post-data"] = "action=removedislike&id=" . $videoId; } parent::__construct("dislike-button", $active, $dislikeCount, $isDisliked); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\Watch8\LikeButton; /** * Define the sparkbars (sentiment bars; like to dislike ratio bar). */ class MSparkbars { /** @var float */ public $likePercent = 50; /** @var float */ public $dislikePercent = 50; public function __construct($likeCount, $dislikeCount) { if (0 != $likeCount + $dislikeCount) { $this->likePercent = ($likeCount / ($likeCount + $dislikeCount)) * 100; $this->dislikePercent = 100 - $this->likePercent; } } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\Watch8\LikeButton; use Rehike\Model\Common\MToggleButton; /** * Define an abstract actual "like button" button (also used for dislikes). */ class MAbstractLikeButton extends MToggleButton { protected $hideNotToggled = true; public $style = "opacity"; public $icon; public $attributes = [ "orientation" => "vertical", "position" => "bottomright", "force-position" => "true" ]; public function __construct($type, $active, $count, $state) { parent::__construct($state); $this->icon = (object) []; $class = "like-button-renderer-" . $type; $this->class[] = $class; $this->class[] = $class . "-" . ($active ? "clicked" : "unclicked"); if ($active) $this->class[] = "yt-uix-button-toggled"; if (!is_null($count)) $this->setText(number_format($count)); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\Watch8\LikeButton; use Rehike\Util\ExtractUtils; /** * Defines the like button (and dislike button) container. * * This stores two copies of both the like and dislike buttons, which are * used for their individual activation states. This is how hitchhiker * handled this. */ class MLikeButtonRenderer { /** @var MLikeButton */ public $likeButton; public $activeLikeButton; /** @var MDislikeButton */ public $dislikeButton; public $activeDislikeButton; /** @var MSparkbars */ public $sparkbars; public function __construct($dataHost, &$info, &$videoId) { if (isset($info->topLevelButtons[0] ->segmentedLikeDislikeButtonRenderer)) { $origLikeButton = $info->topLevelButtons[0]->segmentedLikeDislikeButtonRenderer->likeButton->toggleButtonRenderer ?? null; $origDislikeButton = $info->topLevelButtons[0]->segmentedLikeDislikeButtonRenderer->dislikeButton->toggleButtonRenderer ?? null; } else { $origLikeButton = $info->topLevelButtons[0]->toggleButtonRenderer ?? null; $origDislikeButton = $info->topLevelButtons[0]->toggleButtonRenderer ?? null; } $likeA11y = $origLikeButton->accessibility->label ?? ""; $dislikeA11y = $origDislikeButton->accessibility->label ?? ""; $isLiked = $origLikeButton->isToggled ?? false; $isDisliked = $origDislikeButton->isToggled ?? false; // Extract like count from like count string $likeCount = ExtractUtils::isolateLikeCnt($likeA11y ?? ""); if (is_numeric(str_replace(",", "", $likeCount))) $likeCountInt = (int)str_replace(",", "", $likeCount); // Account for RYD API data if it exists $rydData = &$dataHost::$rydData; if ($dataHost::$useRyd && "" !== $likeCount && isset($rydData->dislikes)) { $dislikeCountInt = (int)$rydData->dislikes; $this->sparkbars = new MSparkbars($likeCountInt, $dislikeCountInt); } $this->likeButton = new MLikeButton(@$likeCountInt, $likeA11y, !$isLiked, $videoId); $this->activeLikeButton = new MLikeButton(@$likeCountInt, $likeA11y, $isLiked, $videoId, true); $this->dislikeButton = new MDislikeButton(@$dislikeCountInt, $dislikeA11y, !$isDisliked, $videoId); $this->activeDislikeButton = new MDislikeButton(@$dislikeCountInt, $dislikeA11y, $isDisliked, $videoId, true); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\Watch8\PrimaryInfo; use Rehike\TemplateFunctions; use Rehike\Model\Common\Subscription\MSubscriptionActions; use Rehike\Model\Common\MButton; use Rehike\Signin\API as SignIn; use Rehike\Util\ExtractUtils; use Rehike\i18n; /** * Defines the video owner information, which appears in the bottom * left corner of the primary info renderer. */ class MOwner { /** @var string */ public $title = ""; /** @var mixed[] */ public $thumbnail; /** @var mixed[] */ public $badges; /** @var object */ public $navigationEndpoint; /** * Defines the subscription actions. * * These include the subscribe button, the notifications button, * and the count at the end. * * @var MSubscriptionActions */ public $subscriptionButtonRenderer; /** * Defines the channel settings button * * @var MButton */ public $channelSettingsButtonRenderer; public function __construct($dataHost) { $secInfo = &$dataHost::$secondaryInfo; $info = $secInfo->owner->videoOwnerRenderer; $i18n = i18n::getNamespace("watch"); $signInInfo = (object) SignIn::getInfo(); $hasChannel = SignIn::isSignedIn() && isset($signInInfo->ucid); if ($hasChannel) $ucid = $signInInfo->ucid; if (isset($info)) { $this->title = $info->title ?? null; $this->thumbnail = $info->thumbnail ?? null; $this->badges = $info->badges ?? null; $this->navigationEndpoint = $info->navigationEndpoint ?? null; // Subscription button $subscribeCount = isset($info->subscriberCountText) ? ExtractUtils::isolateSubCnt(TemplateFunctions::getText($info->subscriberCountText)) : null ; // Build the subscription button from the InnerTube data. if (!SignIn::isSignedIn()) { $this->subscriptionButtonRenderer = MSubscriptionActions::signedOutStub($subscribeCount); } else if (isset($secInfo->subscribeButton->subscribeButtonRenderer)) { $this->subscriptionButtonRenderer = MSubscriptionActions::fromData($secInfo->subscribeButton->subscribeButtonRenderer, $subscribeCount); } else if (isset($secInfo->subscribeButton->buttonRenderer)) { // channel settings button $this->channelSettingsButtonRenderer = new MButton((object) [ "style" => "default", "size" => "default", "text" => (object) [ "simpleText" => $i18n->channelSettings ], "icon" => true, "navigationEndpoint" => (object) [ "commandMetadata" => (object) [ "webCommandMetadata" => (object) [ "url" => "//studio.youtube.com/channel/$ucid/editing/sections" ] ] ], "class" => [ "channel-settings-link" ], "customAttributes" => [ "target" => "_blank" ] ]); } } } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\Watch8\PrimaryInfo; use Rehike\Model\Clickcard\MSigninClickcard; use Rehike\Model\Common\Menu\MMenu; use Rehike\Model\Common\Menu\MMenuItem; use Rehike\Signin\API as SignIn; use Rehike\i18n; class MActionPanelOverflowMenu extends MMenu { public $menuId = "action-panel-overflow-menu"; public function __construct() { $i18n = i18n::getNamespace("watch"); $reportCfg = [ "label" => $i18n->actionReport, "actionPanelTrigger" => "report", "hasIcon" => true ]; if (SignIn::isSignedIn()) { $reportCfg += [ "closeOnSelect" => true ]; } else { $reportCfg += [ "clickcard" => new MSigninClickcard( $i18n->reportClickcardHeading, $i18n->reportClickcardTip, [ "text" => $i18n->clickcardSignIn, "href" => "https://accounts.google.com/ServiceLogin?continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Fnext%3D%252F%253Faction_handle_signin%3Dtrue%26feature%3D__FEATURE__%26hl%3Den%26app%3Ddesktop&passive=true&hl=en&uilel=3&service=youtube" ] ), "attributes" => [ // Clickcard attributes "orientation" => "horizontal", "position" => "topright" ], "fakeActionPanel" => true ]; } $this->items[] = new MMenuItem($reportCfg); $this->items[] = new MMenuItem([ "actionPanelTrigger" => "transcript", "closeOnSelect" => true, "label" => $i18n->actionTranscript, "hasIcon" => true ]); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\Watch8\PrimaryInfo; use Rehike\i18n; class MPrivacyBadge { public string $privacy; public string $tooltip; public function __construct(string $privacy) { $i18n = i18n::getNamespace("watch"); $this->privacy = strtolower(str_replace("PRIVACY_", "", $privacy)); $this->tooltip = match ($privacy) { "PRIVACY_UNLISTED" => $i18n->privacyUnlisted, "PRIVACY_PRIVATE" => $i18n->privacyPrivate, default => "" }; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\Watch8\PrimaryInfo; use Rehike\Model\Common\MButton; use Rehike\Model\Clickcard\MSigninClickcard; use Rehike\Signin\API as SignIn; use Rehike\i18n; /** * Defines an abstract watch action button. * * These are the buttons for watch interaction, such * as add to and share. * * TODO(dcooper): more action button */ class MActionButton extends MButton { // Define default button properties. public $style = "STYLE_OPACITY"; public $icon; public $class = [ "pause-resume-autoplay" ]; public function __construct($data) { parent::__construct([]); $this->icon = (object) []; // Set the button data as provided. $this->setText($data["label"] ?? ""); $this->tooltip = $data["tooltip"] ?? $data["label"]; $this->targetId = $data["id"] ?? null; // Push provided attributes if they exist. if (@$data["attributes"]) foreach ($data["attributes"] as $key => $value) { $this->attributes += [$key => $value]; } if (@$data["class"]) { if (is_string($data["class"])) { $this->class[] = $data["class"]; } else { /* * BUG (kirasicecreamm): This used += operator to * append the arrays, which is useful for associative, * but not numerical arrays. * * This caused it to ignore the 0th item and so on * as it conflicted with the preexisting index in * this parent class. */ $this->class = array_merge($this->class, $data["class"]); } } if (@$data["actionPanelTrigger"]) { $this->class[] = "action-panel-trigger"; $this->class[] = "action-panel-trigger-" . $data["actionPanelTrigger"]; if (!@$data["fakeActionPanel"]) $this->attributes["trigger-for"] = "action-panel-" . $data["actionPanelTrigger"]; // Watch8 only: (if doing w7 in the future edit this) $this->attributes["button-toggle"] = "true"; } if (@$data["clickcard"]) { $this->clickcard = &$data["clickcard"]; } if (@$data["videoActionsMenu"]) { $this->videoActionsMenu = &$data["videoActionsMenu"]; } if (@$data["menu"]) { $this->menu = &$data["menu"]; } } /** * Build a watch8 add to playlists button, or its signed out * stub. * * @return void */ public static function buildAddtoButton($videoId) { $i18n = i18n::getNamespace("watch"); $buttonCfg = [ "label" => $i18n->get("actionAddTo"), "class" => [] ]; if (!SignIn::isSignedIn()) { $buttonCfg += [ "clickcard" => new MSigninClickcard( $i18n->addToClickcardHeading, $i18n->addToClickcardTip, [ "text" => $i18n->clickcardSignIn, "href" => "https://accounts.google.com/ServiceLogin?continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Fnext%3D%252F%253Faction_handle_signin%3Dtrue%26feature%3D__FEATURE__%26hl%3Den%26app%3Ddesktop&passive=true&hl=en&uilel=3&service=youtube" ] ), "attributes" => [ // Clickcard attributes "orientation" => "vertical", "position" => "bottomleft" ] ]; } else { $buttonCfg += [ "videoActionsMenu" => (object)[ "contentId" => "yt-uix-videoactionmenu-menu", "videoId" => $videoId ] ]; $buttonCfg["class"] += [ "yt-uix-menu-trigger", "yt-uix-videoactionmenu-button" ]; } $buttonCfg["class"][] = "addto-button"; return new self($buttonCfg); } /** * Build a watch8 share button. * * @return MActionButton|null */ public static function buildShareButton() { $i18n = i18n::getNamespace("watch"); return new self([ "label" => $i18n->actionShare, "actionPanelTrigger" => "share" ]); } /** * Build a watch8 report button, which is used on livestreams. * * If the video is not a livestream, then the report button appears in * the more button's menu instead. * * @return MActionButton */ public static function buildReportButton() { $i18n = i18n::getNamespace("watch"); $buttonCfg = [ "label" => $i18n->actionReport, "class" => "report-button", "actionPanelTrigger" => "report" ]; if (!SignIn::isSignedIn()) { $buttonCfg += [ "fakeActionPanel" => true, "clickcard" => new MSigninClickcard( $i18n->reportClickcardHeading, $i18n->reportClickcardTip, [ "text" => $i18n->clickcardSignIn, "href" => "https://accounts.google.com/ServiceLogin?continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Fnext%3D%252F%253Faction_handle_signin%3Dtrue%26feature%3D__FEATURE__%26hl%3Den%26app%3Ddesktop&passive=true&hl=en&uilel=3&service=youtube" ] ), "attributes" => [ // Clickcard attributes "orientation" => "horizontal", "position" => "topright" ] ]; } return new self($buttonCfg); } /** * Build a watch8 more button. */ public static function buildMoreButton() { $i18n = i18n::getNamespace("watch"); return new self([ "label" => $i18n->actionMore, "tooltip" => $i18n->actionMoreTooltip, "id" => "action-panel-overflow-button", "menu" => new MActionPanelOverflowMenu() ]); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\Watch8\PrimaryInfo; use Rehike\TemplateFunctions; /** * Define the super title (links that appear above the title, such as hashtags). */ class MSuperTitle { public $items = []; public function __construct($superTitleLink) { if (isset($superTitleLink->runs)) foreach ($superTitleLink->runs as $run) if (" " != $run->text) { $this->items[] = (object)[ "text" => $run->text, "url" => TemplateFunctions::getUrl($run) ]; } } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\Watch7; /** * Implements a model for a notice that displays in * place of a video discussion render, such as in the event * of disabled comments. * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Maintainers */ class MVideoDiscussionNotice { public $message; public function __construct($message) { $this->message = $message; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\Watch7; use Rehike\Model\Common\MButton; class MCreatorBarEditButton extends MButton { public $style = "STYLE_TEXT_DARK"; public function __construct($data) { $this->itemTooltip = $data["tooltip"]; $this->icon = (object) [ "iconType" => $data["icon"] ]; $this->navigationEndpoint = (object) [ "commandMetadata" => (object) [ "webCommandMetadata" => (object) [ "url" => $data["url"] ] ] ]; $this->customAttributes = [ "target" => "_blank" ]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\Watch7; /** * Implements a model for the video discussion renderer. * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Maintainers */ class MVideoDiscussionRenderer { public $continuation; public function __construct($continuation) { $this->continuation = $continuation; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\Watch7; use Rehike\Model\Common\MButton; use Rehike\i18n; use Rehike\Signin\API as SignIn; class MCreatorBar { /** @var MButton[] */ public $navButtons; /** @var MButton[] */ public $editButtons; /** * @var string $vid Video ID. */ public function __construct($vid) { $i18n = i18n::getNamespace("watch"); $ucid = SignIn::getInfo()["ucid"]; $this->navButtons[] = new MButton([ "text" => (object) [ "simpleText" => $i18n->creatorBarAnalytics ], "navigationEndpoint" => (object) [ "commandMetadata" => (object) [ "webCommandMetadata" => (object) [ "url" => "//studio.youtube.com/video/$vid/analytics/tab-overview/period-default" ] ] ], "customAttributes" => [ "target" => "_blank" ] ]); $this->navButtons[] = new MButton([ "text" => (object) [ "simpleText" => $i18n->creatorBarVideoManager ], "navigationEndpoint" => (object) [ "commandMetadata" => (object) [ "webCommandMetadata" => (object) [ "url" => "//studio.youtube.com/channel/$ucid/videos/upload" ] ] ], "customAttributes" => [ "target" => "_blank" ] ]); $this->editButtons[] = new MCreatorBarEditButton([ "tooltip" => $i18n->creatorBarInfo, "icon" => "INFO", "url" => "//studio.youtube.com/video/$vid/edit" ]); $this->editButtons[] = new MCreatorBarEditButton([ "tooltip" => $i18n->creatorBarEnhancements, "icon" => "ENHANCE", "url" => "//studio.youtube.com/video/$vid/editor" ]); $this->editButtons[] = new MCreatorBarEditButton([ "tooltip" => $i18n->creatorBarAudio, "icon" => "AUDIO", "url" => "//studio.youtube.com/video/$vid/editor" ]); $this->editButtons[] = new MCreatorBarEditButton([ "tooltip" => $i18n->creatorBarComments, "icon" => "ANNOTATIONS", "url" => "//studio.youtube.com/video/$vid/comments" ]); $this->editButtons[] = new MCreatorBarEditButton([ "tooltip" => $i18n->creatorBarCards, "icon" => "CARDS", "url" => "//studio.youtube.com/video/$vid/edit" ]); $this->editButtons[] = new MCreatorBarEditButton([ "tooltip" => $i18n->creatorBarSubtitles, "icon" => "CAPTIONS", "url" => "//studio.youtube.com/video/$vid/translations" ]); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\AgeGate; class MPlayerAgeGate { public $reason; public $subreason; public function __construct() { $reason = "Content warning"; $this->reason = (object)["simpleText" => $reason]; $this->subreason = (object)["watch7PlayerAgeGateContent" => new MPlayerAgeGateContent()]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\AgeGate; use Rehike\Model\Common\MButton; class MPlayerAgeGateButton extends MButton { public $style = "STYLE_PRIMARY"; public $role = "link"; public $customAttributes = [ "href" => "https://accounts.google.com/ServiceLogin?hl=en&service=youtube&uilel=3&continue=http%3A%2F%2Fwww.youtube.com%2Fsignin%3Fcontinue_action%3DQUFFLUhqbm5YUkxYSGRlWHphMjAwczlsLTBlcUFzTmpnQXxBQ3Jtc0trV2hlS1FyeWExa3hJQWtuRTB5TXEyckFwVGNuajAwZU5UWXZzM0ZRR0F5X1hISm8ybmczbUdqQkp6VGExTEhrRXdLOG94NmRlbWhYQ3FQcjRiSHFNbkhWV0dBZHdyNzJ3LW9PRFcwd21sQ0dWY05OemRFZV9hZUo2TGFlY0pjaXAyMEp2aEFPcEVBSHktU3d0dEdhdy1JaWhFUU1SWVVKcm9OUGNjSHc2Sm4yZ2t2Rmx4V2NOTm1MT1NQX1lLaEZ2RjZCMGk%253D%26feature%3Dsubscribe%26action_handle_signin%3Dtrue%26next%3D%252Fchannel%252FUCuAXFkgsw1L7xaCfnd5JJOw%26hl%3Den%26app%3Ddesktop&passive=true" ]; public function __construct() { $text = "Sign in to confirm your age"; // TODO: i18n $this->setText($text); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Watch\AgeGate; class MPlayerAgeGateContent { public $message; public $button; public function __construct() { $message = "This video may be inappropriate for some users."; $this->message = $message; $this->button = new MPlayerAgeGateButton(); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Picker; class PickerModel { /** */ public static $flagMap = [ ]; public static function bake($dataHost, $action) { $response = (object) []; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Attribution; use Rehike\i18n; use Rehike\Network; use Rehike\TemplateFunctions; class AttributionModel { public $header; public $contents; public static function bake($dataHost, $videoId) { $i18n = i18n::newNamespace("attribution"); $i18n->registerFromFolder("i18n/attribution"); $response = (object) []; $response->videoId = $videoId; $items = $dataHost->contents->twoColumnBrowseResultsRenderer->tabs[0] ->tabRenderer->content->richGridRenderer->contents ?? null; if (isset($items[0] ->richSectionRenderer)) { $head = $items[0] ->richSectionRenderer->content->sourcePivotHeaderRenderer->headerInformation->profilePageHeaderInformationRenderer ?? null; $header = (object) []; $header->title = $i18n->get('title'); $header->video = (object) []; $header->video->title = $head->title->profilePageHeaderTitleRenderer->title ?? null; $thumb = $head->thumbnail->profilePageHeaderThumbnailRenderer->thumbnail->thumbnails[0] ->url ?? null; // Remove shorts crop $header->video->thumbnail = preg_replace("/\?sqp=.*/", "" , $thumb); $header->video->watchLater = (object) [ "isToggled" => false, "untoggledTooltip" => $i18n->get("watchLater") ]; $response->header = $header; } if(isset($items[1] ->richItemRenderer)) { $contents = (object) []; $contents->title = $i18n->get("sectionTitle"); $contents->subtitle = $i18n->get("sectionSubtitle", TemplateFunctions::getText($header->video->title)); $contents->items = []; for ($i = 1; $i < count($items); $i++) { if (isset($items[$i] ->richItemRenderer)) { $videoId = $items[$i] ->richItemRenderer->content->reelItemRenderer->videoId ?? null; // TODO (kirasicecreamm): I DON'T WANT TO FIX THIS WTF THIS // WILL NEVER WORK OUT 😭😭 // // sfv_audio_pivot doesn't give us adequate data // $reelItem = Request::innertubeRequest("reel/reel_item_watch", (object) [ // "disablePlayerResponse" => true, // "playerRequest" => (object) [ // "videoId" => $videoId // ] // ]); // $reelData = json_decode($reelItem); // $reelHeader = $reelData->overlay->reelPlayerOverlayRenderer->reelPlayerHeaderSupportedRenderers->reelPlayerHeaderRenderer ?? null; // $contents->items[] = (object) []; // $current = $contents->items[array_key_last($contents->items)]; // $thumb = $items[$i] ->richItemRenderer->content->reelItemRenderer->thumbnail->thumbnails[0] ->url ?? null; // $current->thumbnail = preg_replace("/\?sqp=.*/", "", $thumb); // $current->title = $reelHeader->reelTitleText; // $current->author = $reelHeader->channelTitleText; // $current->authorA11yLabel = $i18n->get("goToUser", TemplateFunctions::getText($reelHeader->channelTitleText)); // $current->author->navigationEndpoint = $reelHeader->channelNavigationEndpoint; // $current->attrLink = (object) [ // "simpleText" => $i18n->get("viewAttrs"), // "navigationEndpoint" => (object) [ // "commandMetadata" => (object) [ // "webCommandMetadata" => (object) [ // "url" => "" // ] // ] // ] // ]; // $current->videoId = $videoId; // $current->watchLater = (object) [ // "isToggled" => false, // "untoggledTooltip" => $i18n->get("watchLater") // ]; } } $response->contents = $contents; } return $response; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\History; class HistoryModel { public static function bake($dataHost) { return $dataHost; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Masthead; use Rehike\Model\Common\MButton; use Rehike\i18n; class MAppbarGuideToggle extends MButton { public $style = "STYLE_TEXT"; public $size = "SIZE_DEFAULT"; public $targetId = "appbar-guide-button"; public $class = [ "appbar-guide-toggle", "appbar-guide-clickable-ancestor" ]; public function __construct() { $i18n = i18n::getNamespace("masthead"); $this->accessibility = (object) [ "accessibilityData" => (object) [ "controls" => "appbar-guide-menu", "label" => $i18n->appbarGuideLabel ] ]; $this->icon = (object) [ "iconType" => "APPBAR_GUIDE" ]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Masthead; use Rehike\Model\Common\MButton; use Rehike\i18n; class MSignInButton extends MButton { public $style = "STYLE_PRIMARY"; public $href = "https://accounts.google.com/ServiceLogin?service=youtube&amp;uilel=3&amp;hl=en&amp;continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Fapp%3Ddesktop%26action_handle_signin%3Dtrue%26hl%3Den%26next%3D%252F%26feature%3Dsign_in_button&amp;passive=true"; public function __construct() { $i18n = i18n::getNamespace("masthead"); $this->text = (object) [ "simpleText" => $i18n->signInButton ]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Masthead; use Rehike\Model\Common\MButton; use Rehike\i18n; class MMastheadSearchbox { /** @var string */ public $placeholder; /** @var MButton */ public $button; /** @var bool */ public $autofocus; /** @var string */ public $query; public function __construct() { $i18n = i18n::getNamespace("masthead"); $this->placeholder = $i18n->searchboxPlaceholder; $this->button = new MButton([ "style" => "STYLE_DEFAULT", "size" => "SIZE_DEFAULT", "text" => (object) [ "simpleText" => $i18n->searchboxPlaceholder ], "targetId" => "search-btn", "class" => [ "search-btn-component", "search-button" ], "customAttributes" => (object) [ "type" => "submit", "onclick" => "if (document.getElementById('masthead-search-term').value == '') return false; document.getElementById('masthead-search').submit(); return false;;return true;", "tabindex" => "2", "dir" => "ltr" ] ]); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Masthead; use Rehike\Model\Common\MButton; use Rehike\i18n; use Rehike\Signin\API as SignIn; use Rehike\ConfigManager\ConfigManager as Config; use Rehike\Model\Masthead\{ AccountPicker\MAccountPickerButton, CreationMenu\MCreationMenu, Notifications\MNotificationButton, UploadButton\MUploadButton, UploadButton\MUploadIconButton }; class MMasthead { /** @var string */ public $a11ySkipNav; /** @var MAppbarGuideToggle */ public $guideToggle; /** @var object */ public $logoTooltip; /** @var string */ public $countryCode; /** @var MMastheadSearch */ public $searchbox; /** @var MButton[] */ public $buttons = []; /** @var object */ public $notificationStrings; public function __construct($appbarEnabled) { $i18n = i18n::newNamespace("masthead"); $i18n->registerFromFolder("i18n/masthead"); $this->a11ySkipNav = $i18n->a11ySkipNav; if ($appbarEnabled) $this->guideToggle = new MAppbarGuideToggle(); $this->logoTooltip = $i18n->logoTooltip; $this->searchbox = new MMastheadSearchbox(); $this->notificationStrings = (object) [ "none" => $i18n->notificationsNone, "singular" => $i18n->notificationsSingular, "plural" => $i18n->notificationsPlural, ]; switch (Config::getConfigProp("appearance.uploadButtonType")) { case "BUTTON": $this->buttons[] = new MUploadButton(); break; case "ICON": $this->buttons[] = new MUploadIconButton(); break; default: $this->buttons[] = new MCreationMenu(); break; } if (SignIn::isSignedIn()) { $this->buttons[] = new MNotificationButton(); $this->buttons[] = new MAccountPickerButton(); } else { $this->buttons[] = new MSignInButton(); } } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Masthead\CreationMenu; use Rehike\Model\Common\MButton; class MCreationMenuItem extends MButton { public function __construct($type, $label, $url) { $this->targetId = "creation-$type-menu-item"; $this->type = $type; $this->icon = (object) [ "iconType" => "CREATION_" . strtoupper($type) ]; $this->text = (object) [ "simpleText" => $label ]; $this->navigationEndpoint = (object) [ "commandMetadata" => (object) [ "webCommandMetadata" => (object) [ "url" => $url ] ] ]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Masthead\CreationMenu; use Rehike\Model\Common\MButton; class MCreationMenu extends MButton { public $targetId = "yt-masthead-creation-button"; public $attributes = [ "force-position" => "true", "position-fixed" => "true", "orientation" => "vertical", "position" => "bottomleft" ]; public function __construct() { $this->clickcard = new MCreationClickcard(); $this->icon = (object) []; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Masthead\CreationMenu; use Rehike\i18n; use Rehike\Signin\API as SignIn; class MCreationClickcard { public $template = "masthead_creation_menu"; public $cardClass = [ "yt-scrollbar", "yt-masthead-creation-clickcard" ]; public $id = "yt-masthead-creation-menu"; public $cardId = "yt-masthead-creation-clickcard"; public $content; public function __construct() { $i18n = i18n::getNamespace("masthead"); $signInInfo = (object) SignIn::getInfo(); $hasChannel = SignIn::isSignedIn() && isset($signInInfo->ucid); if ($hasChannel) $ucid = $signInInfo->ucid; $items = []; $items[] = new MCreationMenuItem( "upload", $i18n->creationUpload, $hasChannel ? "//studio.youtube.com/channel/$ucid/videos?d=ud" : "/create_channel?upsell=upload&next=/" ); $items[] = new MCreationMenuItem( "live", $i18n->creationLive, $hasChannel ? "//studio.youtube.com/channel/$ucid/livestreaming" : "/create_channel?upsell=livestreaming&next=/" ); if ($hasChannel) $items[] = new MCreationMenuItem( "post", $i18n->creationPost, $hasChannel ? "/channel/$ucid/community?show_create_dialog=1" : "/create_chanel?upsell=community&next=/" ); $this->content = (object) [ "items" => $items ]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Masthead\UploadButton; use Rehike\Model\Common\MButton; use Rehike\i18n; use Rehike\Signin\API as SignIn; class MUploadIconButton extends MButton { public $targetId = "upload-btn"; public $style = "STYLE_OPACITY"; public function __construct() { $i18n = i18n::getNamespace("masthead"); $signInInfo = (object) SignIn::getInfo(); $hasChannel = SignIn::isSignedIn() && isset($signInInfo->ucid); if ($hasChannel) $ucid = $signInInfo->ucid; $this->tooltip = $i18n->uploadButton; $this->navigationEndpoint = (object) [ "commandMetadata" => (object) [ "webCommandMetadata" => (object) [ "url" => $hasChannel ? "//studio.youtube.com/channel/$ucid/videos?d=ud" : "/create_channel?upsell=upload&next=/" ] ] ]; $this->icon = (object) [ "iconType" => "MATERIAL_UPLOAD" ]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Masthead\UploadButton; use Rehike\Model\Common\MButton; use Rehike\i18n; use Rehike\Signin\API as SignIn; class MUploadButton extends MButton { public $targetId = "upload-btn"; public function __construct() { $i18n = i18n::getNamespace("masthead"); $signInInfo = (object) SignIn::getInfo(); $hasChannel = SignIn::isSignedIn() && isset($signInInfo->ucid); if ($hasChannel) $ucid = $signInInfo->ucid; $this->text = (object) [ "simpleText" => $i18n->uploadButton ]; $this->navigationEndpoint = (object) [ "commandMetadata" => (object) [ "webCommandMetadata" => (object) [ "url" => $hasChannel ? "//studio.youtube.com/channel/$ucid/videos?d=ud" : "/create_channel?upsell=upload&next=/" ] ] ]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Masthead\Notifications; use Rehike\i18n; class MNotificationClickcard { public $template = "masthead_notifications"; public $id = "yt-masthead-notifications"; public $cardAction = "yt.www.notifications.inbox.handleNotificationsClick"; public $cardClass = [ "yt-scrollbar", "yt-notification-inbox-clickcard" ]; public $cardId = "yt-masthead-notifications-clickcard"; public $content; public function __construct() { $i18n = i18n::getNamespace("masthead"); $this->content = (object) []; $this->content->title = $i18n->notificationsTitle; $this->content->button = new MNotificationSettingsButton(); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Masthead\Notifications; use Rehike\Model\Common\MButton; use Rehike\i18n; class MNotificationSettingsButton extends MButton { public $targetId = "yt-masthead-notifications-settings"; public $style = "STYLE_OPACITY"; public function __construct() { $i18n = i18n::getNamespace("masthead"); $this->accessibility = (object) [ "accessibilityLabel" => (object) [ "label" => $i18n->notificationsSettings ] ]; $this->icon = (object) [ "iconType" => "ICON_ACCOUNT_SETTINGS" ]; $this->navigationEndpoint = (object) [ "commandMetadata" => (object) [ "webCommandMetadata" => (object) [ "url" => "/account_notifications" ] ] ]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Masthead\Notifications; use Rehike\Model\Common\MButton; class MNotificationButton extends MButton { public $targetId = "yt-masthead-notifications-button"; public $class = [ "sb-notif-off" ]; public $attributes = [ "force-position" => "true", "position-fixed" => "true", "orientation" => "vertical", "position" => "bottomleft" ]; public function __construct() { $this->accessibility = (object) [ "accessibilityData" => (object) [ "haspopup" => "true" ] ]; $this->icon = (object) [ "iconType" => "BELL" ]; $this->text = (object) [ "simpleText" => "0" ]; $this->clickcard = new MNotificationClickcard(); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Masthead\AccountPicker; use Rehike\Model\Common\MButton; use Rehike\i18n; class MAccountPickerAddButton extends MButton { public $class = ["yt-masthead-picker-button"]; public function __construct() { $i18n = i18n::getNamespace("masthead"); $this->text = (object) [ "simpleText" => $i18n->accountPickerAddAccount ]; $this->navigationEndpoint = (object) [ "commandMetadata" => (object) [ "webCommandMetadata" => (object) [ "url" => "//accounts.google.com/AddSession?passive=false&hl=en&continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Fhl%3Den%26next%3D%252F%253Fdisable_polymer%253D1%26action_handle_signin%3Dtrue%26app%3Ddesktop&uilel=0&service=youtube" ] ] ]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Masthead\AccountPicker; use Rehike\Model\Common\MButton; use Rehike\i18n; use Rehike\Signin\API as SignIn; use Rehike\Model\Common\Thumb\MThumbSquare; use Rehike\Util\ImageUtils; class MAccountPickerButton extends MButton { public $noStyle = true; public $class = [ "yt-masthead-user-icon" ]; public $attributes = [ "force-position" => "true", "position-fixed" => "true", "orientation" => "vertical", "position" => "bottomleft" ]; public function __construct() { $i18n = i18n::getNamespace("masthead"); $signInInfo = (object) SignIn::getInfo(); $this->thumb = new MThumbSquare([ "image" => ImageUtils::changeSize($signInInfo->activeChannel["photo"], 27), "size" => 27, "delayload" => true ]); $this->accessibility = (object) [ "accessibilityData" => (object) [ "label" => $i18n->accountPickerLabel ] ]; $this->clickcard = new MAccountPickerClickcard(); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Masthead\AccountPicker; use Rehike\i18n; use Rehike\Signin\API as SignIn; use Rehike\Model\Common\Thumb\MThumbSquare; use Rehike\Util\ImageUtils; class MAccountPickerClickcard { public $template = "masthead_account_picker"; public $id = "yt-masthead-account-picker"; public $cardAction = "yt.www.masthead.handleAccountPickerClick"; public $cardClass = [ "yt-masthead-account-picker-card", ]; public $class = "yt-masthead-account-picker"; public $content; public function __construct() { $i18n = i18n::getNamespace("masthead"); $signInInfo = (object) SignIn::getInfo(); $activeChannel = $signInInfo->activeChannel; $this->content = (object) []; $content = &$this->content; $content->email = (object) [ "simpleText" => $signInInfo->googleAccount["email"], "navigationEndpoint" => (object) [ "commandMetadata" => (object) [ "webCommandMetadata" => (object) [ "url" => "//myaccount.google.com/u/0" ] ] ] ]; $content->username = $activeChannel["name"]; $content->subCount = $activeChannel["byline"]; $content->photo = (object) [ "simpleText" => $i18n->accountPickerPhotoChange, "navigationEndpoint" => (object) [ "commandMetadata" => (object) [ "webCommandMetadata" => (object) [ "url" => "//myaccount.google.com/u/0/profile#profile_photo" ] ] ], "thumb" => new MThumbSquare([ "image" => ImageUtils::changeSize($activeChannel["photo"], 64), "size" => 64, "delayload" => true ]) ]; $content->buttons = []; $content->buttons[] = new MAccountPickerStudioButton(); $content->buttons[] = new MAccountPickerSettingsButton(); $content->footer = []; $content->footer[] = new MAccountPickerAddButton(); $content->footer[] = new MAccountPickerSignOutButton(); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Masthead\AccountPicker; use Rehike\Model\Common\MButton; use Rehike\i18n; class MAccountPickerSettingsButton extends MButton { public $class = [ "yt-masthead-picker-button", "yt-masthead-picker-settings-button" ]; public function __construct() { $i18n = i18n::getNamespace("masthead"); $this->navigationEndpoint = (object) [ "commandMetadata" => (object) [ "webCommandMetadata" => (object) [ "url" => "/rehike/config" ] ] ]; $this->tooltip = $i18n->accountPickerSettings; $this->icon = (object) [ "iconType" => "ICON_ACCOUNT_SETTINGS" ]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Masthead\AccountPicker; use Rehike\Model\Common\MButton; use Rehike\i18n; use Rehike\Signin\API as SignIn; class MAccountPickerStudioButton extends MButton { public $class = [ "yt-masthead-picker-button", "yt-masthead-picker-button-primary" ]; public function __construct() { $i18n = i18n::getNamespace("masthead"); $signInInfo = (object) SignIn::getInfo(); $hasChannel = SignIn::isSignedIn() && isset($signInInfo->ucid); if ($hasChannel) { $this->text = (object) [ "simpleText" => $i18n->accountPickerStudio ]; $this->navigationEndpoint = (object) [ "commandMetadata" => (object) [ "webCommandMetadata" => (object) [ "url" => "//studio.youtube.com/" ] ] ]; } else { $this->text = (object) [ "simpleText" => $i18n->accountPickerCreate ]; $this->navigationEndpoint = (object) [ "commandMetadata" => (object) [ "webCommandMetadata" => (object) [ "url" => "//www.youtube.com/create_channel" ] ] ]; } $this->customAttributes = [ "target" => "_blank" ]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Masthead\AccountPicker; use Rehike\Model\Common\MButton; use Rehike\i18n; class MAccountPickerSignOutButton extends MButton { public $class = ["yt-masthead-picker-button"]; public function __construct() { $i18n = i18n::getNamespace("masthead"); $this->text = (object) [ "simpleText" => $i18n->accountPickerSignOut ]; $this->navigationEndpoint = (object) [ "commandMetadata" => (object) [ "webCommandMetadata" => (object) [ "url" => "/logout" ] ] ]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Comments; use \Rehike\Model\Common\MButton; class MCommentVoteButton extends MButton { // from MButton public $icon; public $class = [ "comment-action-buttons-renderer-thumb", "sprite-comment-actions" ]; public $attributes = [ "url" => "/comment_service_ajax?action_perform_comment_action=1" ]; /** @var string */ public $type; /** @var string */ public $action; /** @var string */ public $a11yLabel; public function __construct($data) { $this->a11yLabel = $data["a11yLabel"] ?? null; $this->icon = (object) []; $this->class[] = "sprite-" . $data["type"]; $this->class[] = "i-a-v-sprite-" . $data["type"]; $this->attributes["action-type"] = $data["type"]; $this->attributes["action"] = $data["action"]; $this->accessibility = (object) [ "accessibilityData" => (object) [ "checked" => $data["checked"] ? "true" : "false" ] ]; } public static function fromData($data) { $type = strtolower(@$data->defaultIcon->iconType) ?? null; $checked = $data->isToggled ?? false; $action = $checked ? $data->toggledServiceEndpoint->performCommentActionEndpoint->action : $data->defaultServiceEndpoint->performCommentActionEndpoint->action ?? null; $a11yLabel = $checked ? $data->toggledTooltip : $data->defaultTooltip ?? null; return new self([ "type" => $type, "action" => $action, "a11yLabel" => $a11yLabel, "checked" => $checked ]); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Comments; use YukisCoffee\PropertyAtPath; use YukisCoffee\CoffeeRequest\Promise; use \Rehike\Model\Comments\MCommentVoteButton as VoteButton; use \Rehike\Model\Comments\MCommentReplyButton as ReplyButton; use \Rehike\i18n; use \Rehike\ConfigManager\ConfigManager; use \Rehike\Network; use function \Rehike\Async\async; class CommentThread { // Excepted structure is very similar to the InnerTube // comments next response, so this is very basic. const ACTIONS_PATH = "actionButtons.commentActionButtonsRenderer"; const LIKE_BUTTON_PATH = self::ACTIONS_PATH . ".likeButton.toggleButtonRenderer"; const DISLIKE_BUTTON_PATH = self::ACTIONS_PATH . ".dislikeButton.toggleButtonRenderer"; const HEART_BUTTON_PATH = self::ACTIONS_PATH . ".creatorHeart.creatorHeartRenderer"; const REPLY_BUTTON_PATH = self::ACTIONS_PATH . ".replyButton.buttonRenderer"; const COMMON_A11Y_LABEL = "accessibilityData.label"; public static $dataApiData = []; /** * Populate self::$dataApiData with channel data. * * @param string[] $cids List of channel IDs to get display names for. */ public static function populateDataApiData(array $cids) { return async(function() use ($cids) { $response = yield Network::dataApiRequest( action: "channels", params: [ "part" => "id,snippet", "id" => implode(",", $cids) ] ); $data = $response->getJson(); foreach ($data->items as $item) { self::$dataApiData += [ $item->id => $item->snippet ]; } }); } public static function bakeComments($context): Promise { return new Promise(function ($resolve, $reject) use ($context) { // Top-level function // $context = continuation command $context = $context->continuationItems; $out = ["commentThreads" => []]; $cids = []; foreach($context as $comment) { $commentr = $comment->commentThreadRenderer->comment->commentRenderer; if ($a = (@$commentr->authorEndpoint->browseEndpoint->browseId)) { if (!in_array($a, $cids)) $cids[] = $a; } foreach ($commentr->contentText->runs as $run) { if ($a = @$run->navigationEndpoint->browseEndpoint->browseId) { if (!in_array($a, $cids)) $cids[] = $a; } } if (isset($comment->commentThreadRenderer->replies->commentRepliesRenderer->teaserContents)) foreach($comment->commentThreadRenderer->replies->commentRepliesRenderer->teaserContents as $teaser) { $teaser = $teaser->commentRenderer; if ($a = (@$teaser->authorEndpoint->browseEndpoint->browseId)) { if (!in_array($a, $cids)) $cids[] = $a; } foreach ($teaser->contentText->runs as $run) { if ($a = @$run->navigationEndpoint->browseEndpoint->browseId) { if (!in_array($a, $cids)) $cids[] = $a; } } } } self::populateDataApiData($cids) ->then(function() use (&$context, &$out, $resolve) { if (@$context) { for ($i = 0, $count = count($context); $i < $count; $i++) { if (isset($context[$i]->commentThreadRenderer)) { $out["commentThreads"][] = self::commentThreadRenderer( $context[$i]->commentThreadRenderer ); } else if ($count - 1 == $i && isset($context[$i]->continuationItemRenderer)) { $out += [ "commentContinuationRenderer" => self::commentContinuationRenderer( $context[$i]->continuationItemRenderer ) ]; } } } $resolve($out); }); }); } public static function bakeReplies($context): Promise { return new Promise(function ($resolve, $reject) use ($context) { // Top level function // $context = (Array containing all commentRenderer items) $context = @$context->continuationItems; $out = ["comments" => [], "repliesTargetId" => str_replace("comment-replies-item-", "", $context->targetId)]; $cids = []; foreach($context as $comment) { if ($a = $comment->commentRenderer->authorEndpoint->browseEndpoint->browseId) { $cids[] = $a; } foreach ($comment->commentThreadRenderer->comment->commentRenderer->contentText->runs as $run) { if ($a = @$run->navigationEndpoint->browseEndpoint->browseId) { if (!in_array($a, $cids)) $cids[] = $a; } } } self::populateDataApiData($cids) ->then(function() use (&$context, &$out, $resolve) { if ($context) for ($i = 0, $count = count($context); $i < $count; $i++) { if (isset($context[$i]->commentRenderer)) { $out["comments"][] = self::commentRenderer($context[$i]->commentRenderer, true); } else if ($count -1 == $i && isset($context[$i]->continuationItemRenderer)) { $out += ["repliesContinuationRenderer" => self::repliesContinuationRenderer($context[$i]->continuationItemRenderer)]; } } $resolve($out); }); }); } public static function commentThreadRenderer($context) { $out = []; // PLEASE NOTE: // The extra preceding property "comment"/"replies" is removed by this. if (isset($context->comment)) { $out['commentRenderer'] = self::commentRenderer($context->comment->commentRenderer); } if (isset($context->replies)) { $out['commentRepliesRenderer'] = self::commentRepliesRenderer($context->replies->commentRepliesRenderer); } return ['commentThreadRenderer' => $out]; } public static function commentRenderer($context, $isReply = false) { // Right now, the method is to modify a // standard InnerTube response. $context->isReply = $isReply; if (isset($context->voteCount)) self::addLikeCount($context); if ($data = @self::$dataApiData[$context->authorEndpoint->browseEndpoint->browseId]) { $context->authorText = (object) [ "simpleText" => $data->title ]; } // Eliminate surrounding spaces on channel mention and correct mentions foreach ($context->contentText->runs as &$run) { $run->text = str_replace("\u{00A0}", "", $run->text); if ($ucid = @$run->navigationEndpoint->browseEndpoint->browseId) { if (substr($ucid, 0, 2) == "UC" && isset(self::$dataApiData[$ucid])) { $run->text = "@" . self::$dataApiData[$ucid]->title; } } } $context->likeButton = VoteButton::fromData(PropertyAtPath::get($context, self::LIKE_BUTTON_PATH)); $context->dislikeButton = VoteButton::fromData(PropertyAtPath::get($context, self::DISLIKE_BUTTON_PATH)); try { $context->replyButton = ReplyButton::fromData(PropertyAtPath::get($context, self::REPLY_BUTTON_PATH), $context->commentId); } catch(\YukisCoffee\PropertyAtPathException $e) { $context->replyButton = null; } try { $context->creatorHeart = PropertyAtPath::get($context, self::HEART_BUTTON_PATH); } catch (\YukisCoffee\PropertyAtPathException $e) { $context->creatorHeart = null; } return $context; } // WHAT THE FUCK public static function commentRepliesRenderer($context) { if (isset($context->viewReplies)) { $teaser = false /* ConfigManager::getConfigProp("appearance.teaserReplies") */; if (i18n::namespaceExists("comments")) { $i18n = i18n::getNamespace("comments"); } else { $i18n = i18n::newNamespace("comments"); $i18n->registerFromFolder("i18n/comments"); } $viewText = &$context->viewReplies->buttonRenderer->text->runs[0]->text; $hideText = &$context->hideReplies->buttonRenderer->text->runs[0]->text; // YouTube is experimenting with bringing back the // old "View X replies" text format if (!preg_match($i18n->oldReplyTextRegex, $viewText)) { $replyCount = (int) preg_replace($i18n->replyCountIsolator, "", $viewText); if (isset($context->viewRepliesCreatorThumbnail)) { $creatorName = $context->viewRepliesCreatorThumbnail->accessibility->accessibilityData->label; } if ($teaser && $replyCount < 3) { unset($context->viewReplies); unset($context->hideReplies); } else if ($replyCount > 1) { if (isset($creatorName)) { $viewText = $teaser ? $i18n->viewMultiTeaserOwner($replyCount, $creatorName) : $i18n->viewMultiOwner($replyCount, $creatorName); } else { $viewText = $teaser ? $i18n->viewMultiTeaser($replyCount) : $i18n->viewMulti($replyCount); } } else { if (isset($creatorName)) { $viewText = $i18n->viewSingularOwner($creatorName); } else { $viewText = $i18n->viewSingular; } } $hideText = ($replyCount > 1) ? $i18n->hideMulti($replyCount) : $i18n->hideSingular; } } /* * Process teaser contents. */ if (isset($context->teaserContents)) foreach($context->teaserContents as $item) { if (isset($item->commentRenderer)) $item->commentRenderer = self::commentRenderer($item->commentRenderer, true); } return $context; } public static function commentContinuationRenderer($context) { return $context->continuationEndpoint->continuationCommand; } public static function repliesContinuationRenderer($context) { $context = $context->button->buttonRenderer; return [ "token" => $context->command->continuationCommand->token, "text" => $context->text ]; } public static function addLikeCount(&$context) { // Adds to context: /* { "voteCount": { "indifferentText": "2" | (string) Spliced count from accessibility label "likedText": "3" | (string) => (int)++indifferentText } } */ $likeAriaLabel = PropertyAtPath::get($context, self::LIKE_BUTTON_PATH . ".accessibilityData." . self::COMMON_A11Y_LABEL ); $count = (int)self::getLikeCountFromLabel($likeAriaLabel); if (@$context->isLiked) { $context->voteCount = [ "indifferentText" => (string)($count - 1), "likedText" => (string)$count ]; } else { $context->voteCount = [ "indifferentText" => (string)$count, "likedText" => (string)($count + 1) ]; } } public static function getLikeCountFromLabel($label) { if (i18n::namespaceExists("comments")) { $i18n = i18n::getNamespace("comments"); } else { $i18n = i18n::newNamespace("comments"); $i18n->registerFromFolder("i18n/comments"); } return preg_replace($i18n->likeCountIsolator, "", $label); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Comments; use Rehike\TemplateFunctions; use Rehike\Model\Traits\NavigationEndpoint; class CommentsHeader { public $title; public $commentsCountText; public $sortRenderer; public $simpleBoxRenderer; public $createParams; public $commentsCountEndpoint; public static function fromData($data, $id = null) { $new = new self(); if (!is_null($id)) { $new->commentsCountEndpoint = NavigationEndpoint::createEndpoint( "https://www.youtube.com/all_comments?v=$id" ); } if ($a = @$data->titleText) { $new->title = TemplateFunctions::getText($data->titleText); } if ($a = @$data->countText) { $a = $a->runs; $new->commentsCountText = $a[0]->text; } if ($a = @$data->createRenderer) { $new->createParams = $a->commentSimpleboxRenderer->submitButton->buttonRenderer->serviceEndpoint->createCommentEndpoint->createCommentParams ?? null; } if ($a = $data->sortMenu) { $a = $a->sortFilterSubMenuRenderer->subMenuItems; // everything we need in here... $new->sortRenderer = (object) []; $_sr = $new->sortRenderer; // shorthand for ($i = 0; $i < count($a); $i++) { $item = $a[$i]; if ($item->selected) { $_sr->title = $item->title; } $_sr->items[$i] = (object) []; $_sri = $_sr->items[$i]; // shorthand $_sri->title = $item->title; $_sri->selected = $item->selected; $_sri->continuation = $item->serviceEndpoint->continuationCommand->token; // just in case, probably won't do much harm $_sri->menuName = (function() use ($i){ switch($i) { case 0: return 'top-comments'; case 1: return 'newest-first'; } })(); } } if ($a = ($data->createRenderer->commentSimpleboxRenderer ?? false)) { $new->simpleBoxRenderer = (object) []; $_sbr = $new->simpleBoxRenderer; // shorthand $_sbr->authorThumbnail = $a->authorThumbnail; $_sbr->placeholderText = TemplateFunctions::getText($a->placeholderText); } return $new; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Comments; use \Rehike\Model\Common\MButton; use \Rehike\TemplateFunctions; class MCommentReplyButton extends MButton { public $size = "SIZE_SMALL"; public $style = "STYLE_LINK"; public $class = [ "comment-renderer-reply", "comment-simplebox-trigger", ]; public $attributes = [ "simplebox-target" => "/comment_service_ajax?action_create_comment_reply=1" ]; public function __construct($data) { $this->attributes["simplebox-id"] = "comment-simplebox-reply-" . $data["id"]; $this->attributes["simplebox-params"] = $data["params"] ?? null; $this->attributes["simplebox-label"] = $data["label"] ?? ""; $this->attributes["placeholder"] = $data["placeholder"] ?? ""; $this->text = $data["text"]; } public static function fromData($data, $id) { $dialog = $data->navigationEndpoint->createCommentReplyDialogEndpoint->dialog->commentReplyDialogRenderer ?? null; $params = $dialog->replyButton->buttonRenderer->serviceEndpoint->createCommentReplyEndpoint->createReplyParams ?? ""; $label = TemplateFunctions::getText($dialog->replyButton->buttonRenderer->text); $placeholder = TemplateFunctions::getText($dialog->placeholderText); $text = $data->text; return new self([ "id" => $id, "params" => $params, "label" => $label, "placeholder" => $placeholder, "text" => $text ]); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Results; use Rehike\i18n; use Rehike\Model\Common\Subscription\MSubscriptionActions; use Rehike\Util\ExtractUtils; use Rehike\TemplateFunctions; use Rehike\Model\Browse\InnertubeBrowseConverter; class ResultsModel { static $yt; static $response; // Shorthand data references static $filterHeader = null; static $results = null; static $pageFooter = null; /** * Bake a results page model * * @param object $data From search response * @param object $paginatorInfo Info for paginated buttons at the bottom */ public static function bake($data, $paginatorInfo, $query) { $i18n = i18n::newNamespace("results"); $i18n->registerFromFolder("i18n/results"); $response = (object) []; $contents = $data->contents->twoColumnSearchResultsRenderer->primaryContents->sectionListRenderer; $submenu = &$contents->subMenu->searchSubMenuRenderer; if ($filters = @$data->header->searchHeaderRenderer->searchFilterButton->buttonRenderer) { $submenu->button = (object) [ "toggleButtonRenderer" => $filters ]; $submenu->groups = $filters->command->openPopupAction->popup->searchFilterOptionsDialogRenderer->groups; $filters = &$submenu->button->toggleButtonRenderer; unset($filters->command); $filters->defaultText = $filters->text; unset($filters->text); } $submenu -> resultCountText = self::getResultsCount($data) > 1 ? $i18n -> resultCountPlural(number_format(self::getResultsCount($data))) : $i18n -> resultCountSingular(number_format(self::getResultsCount($data))); $filterCrumbs = []; if (isset($submenu->groups)) foreach ($submenu->groups as $group) if (isset($group->searchFilterGroupRenderer)) foreach($group->searchFilterGroupRenderer->filters as $filter) if (@$filter->searchFilterRenderer->status == "FILTER_STATUS_SELECTED" && isset($filter->searchFilterRenderer->navigationEndpoint)) { $filterCrumbs[] = $filter->searchFilterRenderer; } $submenu->filterCrumbs = $filterCrumbs; if (count($filterCrumbs) > 0) { $submenu->clearAll = (object) [ "simpleText" => $i18n->filtersClear, "navigationEndpoint" => (object) [ "commandMetadata" => (object) [ "webCommandMetadata" => (object) [ "url" => "/results?search_query=$query" ] ] ] ]; } for ($i = 0; $i < count($contents->contents); $i++) if (isset($contents->contents[$i] ->itemSectionRenderer)) foreach($contents->contents[$i] ->itemSectionRenderer->contents as $item2) if (isset($item2->promotedSparklesTextSearchRenderer)) { array_splice($contents->contents, $i, 1); } $response->content = InnerTubeBrowseConverter::sectionListRenderer($contents, [ "channelRendererUnbrandedSubscribeButton" => true, "channelRendererChannelBadge" => true ]); // Paginator if (isset($paginatorInfo->pagesCount) && $paginatorInfo->pagesCount > 1) { $response->paginator = new MPaginator($paginatorInfo); } return $response; } public static function getResultsCount($data) { if (isset($data->estimatedResults)) { return (int) $data->estimatedResults; } else { return 0; } } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Results; use Rehike\Controller\ResultsController; use Rehike\i18n; /** * Implements the search paginator model. * * @author Daylin Cooper <[email protected]> * @author The Rehike Maintainers */ class MPaginator { const VISIBLE_PAGE_LINKS = 7; public $pageNumber; public $items; public $hasBackButton = false; public $hasNextButton = false; public function __construct($paginatorInfo) { $this->pageNumber = $paginatorInfo->pageNumber ?? 1; $pagesCount = $paginatorInfo->pagesCount ?? 1; $this->items = self::getVisiblePages($this->pageNumber, $pagesCount); if ($this->pageNumber > $pagesCount) { $this->hasNextButton = true; } if ($this->pageNumber > 1) { $this->hasBackButton = true; } } public static function getVisiblePages($pageNumber, $pagesCount) { $lBound = 1; $rBound = $pagesCount; $displayedPages = []; if ($pagesCount > self::VISIBLE_PAGE_LINKS) { $rangeOffset = 2; $range = $pageNumber + self::VISIBLE_PAGE_LINKS; while ($range < $lBound) $range++; while ($range > $rBound) $range--; while ($pageNumber - $rangeOffset < $lBound) $rangeOffset--; for ($i = $pageNumber - $rangeOffset; $i < $range - $rangeOffset; $i++) { $displayedPages[] = (int) $i; } } else { for ($i = 1; $i < $pagesCount; $i++) { $displayedPages[] = (int) $i; } } $response = []; $strings = i18n::getNamespace("results"); if ($pageNumber > 1) { $response[] = new MPaginatorButton($strings->pagePrev, false, ResultsController::getPageParamUrl(ResultsController::$param, $pageNumber - 1)); } for ($i = 0, $j = count($displayedPages); $i < $j; $i++) { $text = $displayedPages[$i]; $selected = $displayedPages[$i] == $pageNumber; $url = ResultsController::getPageParamUrl(ResultsController::$param, $displayedPages[$i]); $response[] = new MPaginatorButton($text, $selected, $url); } if ($pageNumber < $pagesCount) { $response[] = new MPaginatorButton($strings->pageNext, false, ResultsController::getPageParamUrl(ResultsController::$param, $pageNumber + 1)); } return $response; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Results; use Rehike\Model\Common\MButton; class MPaginatorButton extends MButton { public function __construct($text, $selected, $url) { $this->setText($text); if ($selected) { $this->customAttributes["disabled"] = "True"; $this->attributes["redirect-url"] = $url; } else { $this->navigationEndpoint = (object) [ "commandMetadata" => (object) [ "webCommandMetadata" => (object) [ "url" => $url ] ] ]; } } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Playlist; use \Rehike\Model\Common\MAlert; use \Rehike\i18n; class PlaylistModel { public static function bake($dataHost) { $i18n = i18n::newNamespace("playlist"); $i18n->registerFromFolder("i18n/playlist"); $response = (object) []; $contentContainer = $dataHost->contents->twoColumnBrowseResultsRenderer->tabs[0]->tabRenderer->content ?? null; if (!isset($contentContainer->sectionListRenderer)) { return (object) [ "alerts" => [ new MAlert([ "type" => MAlert::TypeError, "text" => $i18n->nonexistent ]) ] ]; } if ($videoList = @$contentContainer->sectionListRenderer->contents[0]->itemSectionRenderer->contents[0]->playlistVideoListRenderer->contents) { $response->videoList = $videoList; } if ($header = @$dataHost->header->playlistHeaderRenderer) { $response->header = new MPlaylistHeader($header); } if (isset($dataHost->alerts)) { $response->alerts = []; foreach ($dataHost->alerts as $alert) { $alert = $alert->alertWithButtonRenderer ?? $alert->alertRenderer ?? null; $response->alerts[] = MAlert::fromData($alert); } } if ($response == (object) []) { return (object) [ "alerts" => [ new MAlert([ "type" => MAlert::TypeError, "text" => $i18n->unsupported ]) ] ]; } return $response; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Playlist; use Rehike\Util\ParsingUtils; use Rehike\Model\Common\MButton; class MPlaylistHeader { public string $title; public MPlaylistHeaderThumbnail $thumbnail; /** @var object[] */ public array $details = []; /** @var MButton[] */ public array $actions = []; public function __construct(object $data) { // Title $this->title = ParsingUtils::getText($data->title); // Thumbnail $thumbnail = $data->playlistHeaderBanner->heroPlaylistThumbnailRenderer; if (isset($thumbnail->thumbnail)) { $this->thumbnail = new MPlaylistHeaderThumbnail( ParsingUtils::getThumb($thumbnail->thumbnail, 126), ParsingUtils::getUrl($thumbnail->onTap), ParsingUtils::getText($thumbnail->thumbnailOverlays->thumbnailOverlayHoverTextRenderer->text), ParsingUtils::getUrl($data->ownerEndpoint) . "/playlists" ); } // Details (author, views, etc.) $this->details[] = (object) [ "simpleText" => ParsingUtils::getText($data->ownerText), "navigationEndpoint" => $data->ownerEndpoint ]; foreach ($data->byline as $byline) { $this->details[] = (object) [ "simpleText" => ParsingUtils::getText($byline->playlistBylineRenderer->text) ]; } // Actions (play all, share, save) if (isset($data->playButton->buttonRenderer)) { $this->actions[] = new MButton([ "text" => $data->playButton->buttonRenderer->text, "navigationEndpoint" => $data->playButton->buttonRenderer->navigationEndpoint, "icon" => true, "class" => [ "playlist-play-all", "play-all-icon-btn" ] ]); } } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Playlist; class MPlaylistHeaderThumbnail { public function __construct( public string $thumbnail, public string $url, public string $playAllText, public string $allPlaylistsUrl ) {} }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\AllComments; use Rehike\Util\ParsingUtils; use Rehike\i18n; use Rehike\Model\Comments\CommentThread; use Rehike\Model\Comments\CommentsHeader; class AllCommentsModel { public static function bake(object $sdata, object $cdata, string $id): object { $i18n = i18n::newNamespace("all_comments")->registerFromFolder("i18n/all_comments"); $response = (object) []; foreach ($sdata->contents->twoColumnSearchResultsRenderer->primaryContents->sectionListRenderer->contents as $content) { if (isset($content->itemSectionRenderer)) { foreach ($content->itemSectionRenderer->contents as $icontent) { if (@$icontent->videoRenderer->videoId == $id) { $response->video = $icontent; } } } } if (!isset($response->video)) header("Location: /oops"); $response->title = $i18n->pageTitle(ParsingUtils::getText($response->video->videoRenderer->title)); $response->comments = (object) []; $response->comments->headerRenderer = CommentsHeader::fromData($cdata->onResponseReceivedEndpoints[0]->reloadContinuationItemsCommand->continuationItems[0]->commentsHeaderRenderer); CommentThread::bakeComments($cdata->onResponseReceivedEndpoints[1]->reloadContinuationItemsCommand) ->then(function($comments) use (&$response) { $response->comments->comments = $comments; }); return $response; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Share; use Rehike\Model\Common\MButton; class MShareTabBar { /** @var MButton[] */ public $tabs = []; public function __construct($tabs) { for ($i = 0; $i < count($tabs); $i++) { $this->tabs[] = new MButton([ "style" => "STYLE_TEXT", "text" => (object) [ "simpleText" => $tabs[$i] ->text ?? "" ], "class" => [ "share-panel-" . $tabs[$i] ->type, "yt-card-title", $tabs[$i] ->active ? "yt-uix-button-toggled" : "" ], "attributes" => [ "button-toggle" => "true" ] ]); } } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Share; use \Rehike\Model\Common\MAlert; use Rehike\i18n; use Rehike\Model\Share\MShareTabBar; class ShareEmbedModel { public static function bake($videoId, $title, $listData) { $response = (object) []; $i18n = i18n::newNamespace("share"); $i18n -> registerFromFolder("i18n/share"); $alternateUrls = []; if ($listData != null) { $playlistHost = $listData -> contents -> twoColumnBrowseResultsRenderer -> tabs[0] -> tabRenderer -> content ?? null; if (!isset($playlistHost -> sectionListRenderer)) { return (object) [ "alerts" => [ new MAlert([ "type" => MAlert::TypeError, "text" => $i18n -> playlistNonexistent ]) ] ]; } $listId = $listData -> header -> playlistHeaderRenderer -> playlistId; $videoList = $playlistHost -> sectionListRenderer -> contents[0] -> itemSectionRenderer -> contents[0] -> playlistVideoListRenderer -> contents; if (count($videoList) <= 0) { return (object) [ "alerts" => [ new MAlert([ "type" => MAlert::TypeError, "text" => $i18n -> playlistNoVideos ]) ] ]; } $firstVideoId = $videoList[0]->playlistVideoRenderer->videoId; $response->embedUrl = "https://www.youtube.com/embed/$videoId?list=$listId"; $response->isList = true; $alternateUrls = [ (object) [ "key" => "first", "content" => "https://www.youtube.com/embed/$firstVideoId?list=$listId" ], (object) [ "key" => "default", "content" => $response->embedUrl ], (object) [ "key" => "nolist", "content" => "https://www.youtube.com/embed/$videoId" ] ]; } else { $response->embedUrl = "https://www.youtube.com/embed/$videoId"; $response->isList = false; } $response -> alternateUrls = $alternateUrls; $response -> strs = $i18n; $sizes = [ (object) [ "name" => "default", "width" => "560", "height" => "315" ], (object) [ "name" => "hd720", "width" => "1280", "height" => "720" ], (object) [ "name" => "large", "width" => "853", "height" => "450" ], (object) [ "name" => "default", "width" => "640", "height" => "360" ], (object) [ "name" => "default", "text" => $i18n -> get("customSize") ] ]; $options = [ (object) [ "name" => "show-related", "text" => $i18n -> get("showRelated"), "active" => true ], (object) [ "name" => "show-controls", "text" => $i18n -> get("showControls"), "active" => true ], (object) [ "name" => "show-info", "text" => $i18n -> get("showInfo"), "active" => true ], (object) [ "name" => "delayed-cookies", "text" => $i18n -> get("delayedCookies"), "url" => "http://www.google.com/support/youtube/bin/answer.py?answer=171780&expand=PrivacyEnhancedMode#privacy", "active" => false ] ]; $response -> options = $options; $response -> sizes = $sizes; return $response; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Share; use Rehike\i18n; use Rehike\Model\Share\MShareTabBar; class ShareBoxModel { public static function bake($videoId, $title, $listId) { $response = (object) []; $i18n = i18n::newNamespace("share"); $i18n->registerFromFolder("i18n/share"); $shortUrl = "https://youtu.be/" . ($listId ? "$videoId?list=$listId" : $videoId); $response->shortUrl = $shortUrl; $response->videoId = $videoId; $response->startStr = $i18n->get("startAt"); $tabs = new MShareTabBar([ (object) [ "text" => $i18n->get("tabShare"), "type" => "services", "active" => true ], (object) [ "text" => $i18n->get("tabEmbed"), "type" => "embed", "active" => false ], (object) [ "text" => $i18n->get("tabEmail"), "type" => "email", "active" => false ] ]); $response->tabs = $tabs->tabs; $services = []; $fullUrl = "https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D$videoId%26feature%3Dshare"; $thumbnail = "https%3A%2F%2Fi.ytimg.com%2Fvi%2F$videoId%2Fmaxresdefault.jpg"; $services[] = (object) [ "icon" => "facebook", "tooltip" => $i18n->get("serviceTooltip", "Facebook"), "url" => "https://www.facebook.com/dialog/share?app_id=87741124305&href=$fullUrl&display=popup", "width" => 530, "height" => 560 ]; $services[] = (object) [ "icon" => "twitter", "tooltip" => $i18n->get("serviceTooltip", "Twitter"), "url" => "https://twitter.com/intent/tweet?url=$fullUrl&text=$title&via=YouTube&related=YouTube%2CYouTubeTrends%2CYTCreators", "width" => 550, "height" => 420 ]; $services[] = (object) [ "icon" => "blogger", "tooltip" => $i18n->get("serviceTooltip", "Blogger"), "url" => "https://www.blogger.com/blog-this.g?n=$title&source=youtube&b=%3Ciframe+width%3D%22480%22+height%3D%22270%22+src%3D%22https%3A%2F%2Fwww.youtube.com%2Fembed%2F$videoId%22+frameborder%3D%220%22+allow%3D%22accelerometer%3B+autoplay%3B+encrypted-media%3B+gyroscope%3B+picture-in-picture%22+allowfullscreen%3E%3C%2Fiframe%3E&eurl=$thumbnail&quot=", "width" => 768, "height" => 468 ]; $services[] = (object) [ "icon" => "reddit", "tooltip" => $i18n->get("serviceTooltip", "reddit"), "url" => "https://www.reddit.com/submit?url=$fullUrl&title=$title", "width" => 1024, "height" => 650 ]; $services[] = (object) [ "icon" => "tumblr", "tooltip" => $i18n->get("serviceTooltip", "Tumblr"), "url" => "https://www.tumblr.com/widgets/share/tool?shareSource=legacy&url=$fullUrl&posttype=video&content=$fullUrl&caption=$title", "width" => 1024, "height" => 650 ]; $services[] = (object) [ "icon" => "pinterest", "tooltip" => $i18n->get("serviceTooltip", "Pinterest"), "url" => "https://pinterest.com/pin/create/button/?url=$fullUrl&description=$title&is_video=true&media=$thumbnail", "width" => 1024, "height" => 650 ]; $services[] = (object) [ "icon" => "vkontakte", "tooltip" => $i18n->get("serviceTooltip", "ВКонтакте"), "url" => "https://vkontakte.ru/share.php?url=$fullUrl", "width" => 1024, "height" => 650 ]; $services[] = (object) [ "icon" => "linkedin", "tooltip" => $i18n->get("serviceTooltip", "LinkedIn"), "url" => "https://www.linkedin.com/shareArticle?url=$fullUrl&title=$title&summary=$title&source=Youtube", "width" => 1024, "height" => 650 ]; $response->services = $services; return $response; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Debugger; /** * Implements the dialog model for the Rehike debugger. * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Developers */ class MDialog { /** * The dialog's header. * * @var MDialogHeader */ public $header; /** * Stores whether or not the debugger is in condensed mode. * * @var bool */ public $condensed; /** * An array of tabs. * * @var MTab[] */ public $tabs = []; public function __construct($condensed) { $this->header = new MDialogHeader($condensed); } /** * Add a tab to the dialog. * * @param MTab $tab * @return MTabContent Reference to the tab's content. */ public function &addTab($tab) { $this->tabs[] = $tab; return $this->tabs[count($this->tabs) - 1]->content; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Debugger; /** * Implements the tab content wrapper. * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Developers */ abstract class MTabContent { use RichContent; /** * Determines if the tab should be affected by the JS history manager * on the client-side. * * Generally, this should be true for tabs that update via HTML and false * for tabs that update via other methods. * * @var bool */ public $enableJsHistory = true; /** * Create a tab model and automatically wrap it. This should be the general * way of creating a tab. * * @param string $title Title of the tab. * @param string $id Unique ID for the tab. * @param bool $selected Whether or not the tab is selected. */ public static function createTab($title, $id, $selected = false) { $me = new static(); return new MTab($title, $id, $me, $selected); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Debugger; use Rehike\i18n; /** * Implements the Rehike Debugger "Nothing to See" renderer. * * This is a general placeholder that can be used when there's no content * to display. * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Developers */ class MNothingToSee { public $text; public function __construct() { $i18n = &i18n::getNamespace("rebug"); $this->text = $i18n->nothingToSee; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Debugger; use Rehike\Debugger\ErrorWrapper; /** * Implements the error tab. * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Developers */ class MErrorTab extends MTabContent { public function __construct() {} /** * Push a list of errors from the debugger's main API to the error tab. * * @param ErrorWrapper[] $errors * @return void */ public function pushErrors($errors) { $errorCount = count($errors); if ($errorCount != 0) { foreach ($errors as $error) { $this->addError($error); } } else { $this->addNothingToSee(); } } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Debugger; use \Rehike\i18n; /** * Implements the dialog header. * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Developers */ class MDialogHeader { /** * Title of the header. * * @var string */ public $title; /** * A button to close the dialog. * * @var MDialogHeaderCloseButton */ public $closeButton; /** * Help link for condensed mode. * * @var object */ public $helpLink; /** * History button (unused) * * @var MHistoryButton */ public $historyButton; /** * Create a new dialog header. * * @param bool $condensed Is the debugger condensed? * @parma bool $closeButton Whether or not to include the close button. */ public function __construct($condensed, $closeButton = true) { $i18n = &i18n::getNamespace("rebug"); $this->title = !$condensed ? $i18n->debuggerTitle : $i18n->condensedDebuggerTitle; if ($condensed) { $this->helpLink = (object) [ "text" => $i18n->condensedDebuggerHelpLink, "href" => "//github.com/Rehike/Rehike/wiki/Creating-an-issue" ]; } if (!$condensed) { $this->historyButton = new MHistoryButton(); } if ($closeButton) { $this->closeButton = new MDialogHeaderCloseButton(); } } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Debugger; /** * Implements a generic "loading" tab for tabs that primarily * render with JS. * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Developers */ class MLoadingTab extends MTabContent { // This should not update over SPF public $enableJsHistory = false; public function __construct() { $this->addLoading(); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Debugger; use \Rehike\i18n; use \Rehike\Debugger\ErrorWrapper; use \Rehike\Model\Common\MButton; /** * A general trait for rich text content as used by the * debugger. * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Developers */ trait RichContent { /** * Stores rich content, which is a versatile way to implement debugger * content. * * @param object[] */ public $richDebuggerRenderer = []; /** * Add a rich text wrapper that can be typed. * * @param string $type Type of the text to be tested upon. * @param ?string $text Text to assign. * @param array $custom Associative array of custom attributes. * * @return void */ public function addRichText($type, $text = null, $custom = []) { $obj = []; if (null != $text) $obj["text"] = $text; if (!empty($custom)) $obj += $custom; $this->richDebuggerRenderer[] = (object)[ $type => (object)$obj ]; } /** * Add a heading to the renderer. * * @param string $text * @return void */ public function addHeading($text) { $this->addRichText("heading", $text); } /** * Add a subheading to the renderer. * * @param string $text * @return void */ public function addSubheading($text) { $this->addRichText("subheading", $text); } /** * Add a generic text renderer to the renderer. * * @param string $text * @return void */ public function addText($text) { $this->addRichText("simpleText", $text); } /** * Add a generic code renderer to the renderer. * * @param string $text * @return void */ public function addCode($text) { $this->addRichText("code", $text); } /** * Add a button to the renderer. * * @param MButton $button * @return void */ public function addButton($button) { $this->richDebuggerRenderer[] = (object)[ "button" => $button ]; } /** * Add an error renderer to the rich content array. * * @param ErrorWrapper $error * @return void */ public function addError($error) { $i18n = &i18n::getNamespace("rebug"); // Get error information from the ID switch ($error->errno) { case E_ERROR: case E_USER_ERROR: $type = "error"; $errorTypeText = $i18n->errorError ?? "Error"; break; case E_WARNING: case E_USER_WARNING: $type = "warning"; $errorTypeText = $i18n->errorWarning ?? "Warning"; break; case E_DEPRECATED: case E_USER_DEPRECATED: $type = "deprecated"; $errorTypeText = $i18n->errorDeprecated ?? "Deprecated"; break; case E_NOTICE: case E_USER_NOTICE: $type = "notice"; $errorTypeText = $i18n->errorNotice ?? "Notice"; break; } // Get the short filename $shortFile = $error->errfile; $shortFile = explode("/", str_replace("\\", "/", $shortFile)); $shortFile = $shortFile[count($shortFile) - 1]; $this->richDebuggerRenderer[] = (object)[ "errorRenderer" => (object)[ "number" => $error->errno, "file" => $error->errfile, "shortFile" => $shortFile, "message" => $error->errstr, "line" => $error->errline, "type" => $type, "errorTypeText" => $errorTypeText ] ]; } /** * Add a nothing to see placeholder to the renderer. * * @return void */ public function addNothingToSee() { $this->richDebuggerRenderer[] = (object)[ "nothingToSeeRenderer" => new MNothingToSee() ]; } /** * Add a loading placeholder to the renderer. * * @return void */ public function addLoading() { $this->richDebuggerRenderer[] = (object)[ "loadingRenderer" => true ]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Debugger; use Rehike\Debugger\Debugger; use ReflectionObject, ReflectionProperty, ReflectionMethod; /** * Implements the global walker tab. * * Note on nomenclature: The first revision of the debugger called the global * walker "$yt walker" after the global $yt object. The name of this class * still reflects that earlier era. * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Developers */ class MYtWalker extends MTabContent { public function __construct() {} /** * JS history should not be allowed on this tab, as it is rendered and * controlled by the JS land. */ public $enableJsHistory = false; /** * Adds a reference to the global data object ($yt). * * @param object $yt Global object * @return void */ public function addYt($yt) { $this->richDebuggerRenderer[] = (object)[ "globalWalkerContainer" => (object)[ "items" => $yt ] ]; Debugger::addContext("jsAttrs", self::getAttrs($yt)); } /** * Get the attributes of $yt. * * @param object $yt Global object * @return array Associative array of additional property information. */ public static function getAttrs($yt) { $attrs = []; self::getAttrsOfObj($attrs, $yt, "yt"); return $attrs; } /** * Get the attributes of an object and write them to an associative * array. * * This is used to communicate PHP-specific data outside of PHP while * maintaining the use of JSON otherwise. A path is simply provided by * the PHP server with additional properties that the client can then parse. * * Contrary to the name, this function supports both object and array input. * The methods for obtaining metadata differ, so this function has quite a * complex body. * * TODO: Cleanup. * * @param array $attrs Associative array to write property information to. * @param object|array $obj Object to get information from. * @param string $path Path to find $obj at (used recursively). * * @return void Writes to $attrs as reference. */ public static function getAttrsOfObj(&$attrs, $obj, $path) { // Reflection is not used to read arrays, only objects. $usingReflection = false; /** * PATCH (kirasicecreamm): Prevent obvious memory leak from recursion. * * The simple solution is to keep a parent stack and check if the * requested value is present on it, stopping in our tracks if we need * to. */ static $parentStack = []; if (is_object($obj)) { /* * Objects must be iterated differently from arrays. This is because * not all objects are iterable, objects can have hidden properties, * and objects can have methods. * * In order to use the same code for iterating an array and an * object using foreach, a ReflectionObject is created to convert * the data to an array that can then be iterated. */ $reflection = new ReflectionObject($obj); $source = array_merge( $reflection->getProperties(), $reflection->getMethods() ); // As reflection is used to read properties, this is set to true // for future reference. $usingReflection = true; } else { // Otherwise it's just an array and it can already be iterated. $source = $obj; } foreach ($source as $key => $value) { /* * Object-specific operations: * - Get the value of a protected or private property. * - Report the original privacy. * - Create a placeholder for method values. */ if ($usingReflection) // object input { /** * ReflectionProperty and ReflectionMethod share roughly * the same API, so they can be used interchangeably. * * However, they don't come from the same base class or * implement a common interface, so they must be regarded as * two separate types. * * @var ReflectionProperty|ReflectionMethod */ $reflection = $source[$key]; $key = $reflection->getName(); if ($value instanceof ReflectionProperty) { /* * PATCH (dcooper): Required before PHP 8.1, else a * ReflectionException is thrown upon trying to access the * contents of a protected or private property. */ $reflection->setAccessible(true); /** * PATCH (kirasicecreamm): ReflectionProperty::getValue() * will cause a fatal error when attempting to read an * uninitalised *typed* property. */ if ($reflection->isInitialized($obj)) { $value = $reflection->getValue($obj); } else { $value = "uninitialized"; } } else if ($value instanceof ReflectionMethod) { $value = "[function]"; } if ($reflection->isPrivate() || $reflection->isProtected()) { self::defineAttr($attrs, $path, $key, [ "privacy" => $reflection->isPrivate() ? "private" : "protected" ]); } } else // array input { $value = $source[$key]; } // Search by type if (is_object($value)) { if (false === array_search($value, $parentStack)) { $parentStack[] = &$value; if ("stdClass" != get_class($value)) { self::defineAttr($attrs, $path, $key, [ "type" => get_class($value) ]); } // Also deep iterate self::getAttrsOfObj($attrs, $value, "$path.$key"); } else { $value = "[ infinite cycle detected ]"; } array_pop($parentStack); } else if (is_array($value)) { if (false === array_search($value, $parentStack)) { $parentStack[] = &$value; if (self::isAssociativeArray($value)) { self::defineAttr($attrs, $path, $key, [ "associativeArray" => true ]); } // Also deep iterate self::getAttrsOfObj( $attrs, $value, "$path.$key", true ); } else { $value = "[ infinite cycle detected ]"; } array_pop($parentStack); } else if (is_callable($value)) { self::defineAttr($attr, $path, $key, [ "function" => true ]); } } } /** * Define an attribute definition on the attrs associative array. * * @param array $attrs Associative array of attributes. * @param string $path Path to write to. * @param string $key Key to define. * @param mixed $attr Value to set. */ public static function defineAttr(&$attrs, $path, $key, $attr) { if (!isset($attrs["$path.$key"])) { $attrs["$path.$key"] = $attr; } else { $attrs["$path.$key"] += $attr; } } /** * Determine if an array is an associative array. * * @param array $arr * @return bool */ public static function isAssociativeArray($arr) { return count(array_filter(array_keys($arr), 'is_string')) > 0; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Debugger; use \Rehike\i18n; use \Rehike\Version\VersionController; use \Rehike\Model\Common\MButton; /** * Implements the Rehike debugger popup open button. * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Developers */ class MOpenButton extends MButton { public $style = "STYLE_OPACITY"; public $class = [ "yt-uix-button-reverse", "rebug-open-button" ]; public function __construct($errorCount, $condensed) { if ($condensed) $this->class[] = "condensed"; if ($errorCount > 0) $this->class[] = "rebug-open-button-has-error"; $this->setText(self::getTitle($errorCount, $condensed)); $this->hasArrow = true; } /** * Get the title to be used by the open button. * * @param int $errorCount Number of errors that have occurred. * @param bool $condensed Different strings are used if the debugger is * condensed. * @return string */ public static function getTitle($errorCount = 0, $condensed = false) { $i18n = &i18n::getNamespace("rebug"); $label = ""; if (!$condensed) { /* * When the debugger is not in condensed mode, the title will * report version information and error information if it occurs, * as such: * "[email protected] (2 errors)" */ $label = $i18n->openButtonLabel; // Attempt to get version from version service $versionInfo = &VersionController::$versionInfo; if (isset($versionInfo)) { // Append the @rehike string if version is available; // "Debugger@rehike" $label .= "@rehike"; $branch = $versionInfo["branch"] ?? null; $revId = $versionInfo["currentRevisionId"] ?? null; // Append the branch if it's available; // "[email protected]" if (null != $branch) { $label .= ".$branch"; } // Append the revision ID (commit index) if it is available; // "[email protected]" if (null != $revId) { $label .= ".$revId"; } } } else { /* * When the debugger is in condensed mode, the button should not * show at all. This is actually legacy behaviour since the button * is not shown at all in condensed mode if no errors have occurred. */ $label = ""; } /* * The button also must report the number of errors that have occurred * so that the developer can easily see it at a glance. */ if ($errorCount > 0) { if (!$condensed) { /* * When not in condensed mode, append the error count to the * end of the existing label; * "[email protected] (1 error)" * "[email protected] (6 errors)" */ if (1 == $errorCount) { $label .= " " . $i18n->openButtonErrorCountSingular; } else { $label .= " " . $i18n->openButtonErrorCountPlural( number_format($errorCount) ); } } else { /* * Condensed mode should instead make a true label for the first * time that indicates simply that an error has occurred; * "An error has occurred. Click to learn more." * "6 errors have occurred. Click to learn more." */ if (1 == $errorCount) { $label = $i18n->condensedButtonLabelSingular; } else { $label = $i18n->condensedButtonLabelPlural( number_format($errorCount) ); } } } return $label; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Debugger; /** * Implements the tab wrapper. General use should use the * createTab method of a MTabContent child. * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Developers */ class MTab { /** * The title of a tab. * * @var string */ public $title; /** * A unique identifier for this tab. * * @var string */ public $id = ""; /** * Determines if the tab should be selected by default. * * @var bool */ public $selected = false; /** * Stores the content of the tab. * * @var MTabContent */ public $content; /** * Construct a new tab wrapper. * * @param string $title Title of the tab * @param string $id Unique ID for the tab * @param MTabContent $content Content of the tab * @param bool $selected Whether or not to select the tab. */ public function __construct($title, $id, $content, $selected) { $this->title = $title; $this->id = $id; $this->content = $content; $this->selected = $selected; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Debugger; use Rehike\i18n; use Rehike\Model\Common\MButton; /** * Implements the history button for the debugger. * * This is used by the client to navigate previous pages' states, which are * stored in memory on the client-side. * * This feature is currently a work in progress. * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Maintainers */ class MHistoryButton extends MButton { public $class = ["rebug-history-button"]; public $attributes = []; public function __construct() { $i18n = i18n::getNamespace("rebug"); $this->setText($i18n->historyCurrent); /* * HTML attributes used for client-side string generation. */ $this->attributes = [ "label-current-page" => $i18n->historyCurrent, "label-previous-page" => $i18n->historyPrevious, "label-n-pages-ago" => $i18n->historyPagesAgo, "label-unavailable" => $i18n->historyUnavailable ]; $this->hasArrow = true; $this->disabled = true; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Debugger; /** * TODO!! * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Developers */ class MNetworkTab extends MTabContent { // This should not update over SPF public $enableJsHistory = false; public function __construct() { } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Debugger; use \Rehike\i18n; use \Rehike\Model\Common\MButton; /** * Implements the close button used in the header. This is used in the JS * world to close the dialog. * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Maintainers */ class MDialogHeaderCloseButton extends MButton { public $style = "STYLE_OPACITY"; public $icon; public $class = [ "rebug-close-button" ]; public $tooltip; public function __construct() { $i18n = &i18n::getNamespace("rebug"); $this->tooltip = $i18n->debuggerClose; $this->icon = (object) [ "iconType" => "CLOSE" ]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Version; use Rehike\i18n; class MExtraInfo { public string $headingText; /** @var string[][] */ public array $info = []; public function __construct() { $strings = i18n::getNamespace("rehike/version"); $this->headingText = $strings->extraInfo; $this->info[] = [ $strings->operatingSystem, php_uname("s") . " " . php_uname("r") . " " . php_uname("v") . " " . php_uname("m") ]; $this->info[] = [ $strings->phpVersion, phpversion() ]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Version; use Rehike\i18n; class MFailedNotice extends MNotice { public function __construct() { $strings = i18n::getNamespace('rehike/version'); $this->text = $strings->failedNotice; $this->description = $strings->noDotVersionNotice; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Version; use Rehike\i18n; class MNonGitNotice extends MNotice { public function __construct() { $strings = i18n::getNamespace('rehike/version'); $this->text = $strings->nonGitNotice; $this->description = $strings->nonGitExtended; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Version; use Rehike\i18n; class MNotice { public $text; public $description; }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Version; use Rehike\i18n; class MVersionPage { public $headingText; public $brandName; public $version = ""; // This gets replaced later public $nightlyNotice; public $nightlyInfo; public $failedNotice; public $nonGitNotice; public $extraInfo; protected $isNightly = false; public function __construct($data) { $strings = i18n::getNamespace('rehike/version'); $this->headingText = $strings->headingVersionInfo; $this->brandName = $strings->brandName; if (@$data["semanticVersion"]) { $this->version = $strings->versionHeader($data["semanticVersion"]); } if (!@$data["isRelease"] && null != $data) { $this->nightlyNotice = new MNightlyNotice(); $this->nightlyInfo = new MNightlyInfo($data); $this->isNightly = true; } if (null == $data) { $this->failedNotice = new MFailedNotice(); unset($this->brandName); return; } if (!@$data["supportsDotGit"]) { $this->nonGitNotice = new MNonGitNotice(); } $this->extraInfo = new MExtraInfo(); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Version; use Rehike\i18n; class MNightlyNotice { public $text; public $tooltip; public function __construct() { $strings = i18n::getNamespace('rehike/version'); $this->text = $strings->nightly; $this->tooltip = $strings->nightlyInfoTooltip; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Version; use Rehike\Controller\Version\GetVersionController as Controller; use Rehike\i18n; class MNightlyInfo { public $headingText; public $branch; public $commitHash; public $fullCommitHash; public $isPreviousHash = false; public $commitName; public $commitDateTime; public $ghButton; public function __construct(&$data) { $strings = i18n::getNamespace('rehike/version'); if ($branch = @$data["branch"]) { $this->headingText = $strings->subheaderNightlyInfo; $this->branch = $branch; } if ($hash = @$data["currentHash"]) { $this->commitHash = self::trimHash($hash); $this->fullCommitHash = $hash; } else if ($hash = @$data["previousHash"]) { $this->commitHash = self::trimHash($hash); $this->fullCommitHash = $hash; $this->isPreviousHash = true; } if ($name = @$data["subject"]) { $this->commitName = $name; } if ($time = @$data["time"]) { $this->commitDateTime = $strings->get("getFormattedDate")($time); } if (Controller::GH_ENABLED && @$this->fullCommitHash) { $this->ghButton = (object)[]; $this->ghButton->label = $strings->viewOnGithub; $this->ghButton->endpoint = "//github.com/" . Controller::GH_REPO . "/tree/{$this->fullCommitHash}"; } } private static function trimHash($hash) { return substr($hash, 0, 7); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Config; use Rehike\i18n; use Rehike\Model\Traits\NavigationEndpoint; use Rehike\RehikeConfigManager as ConfigManager; use Rehike\Model\Common\MButton; use Rehike\Model\Common\MAlert; class ConfigModel { public static function bake($tab, $status = null) { $response = (object) []; $i18n = i18n::newNamespace("rehike/config") ->registerFromFolder("i18n/rehike/config"); $tabs = (object) $i18n->tabs; $props = json_decode(json_encode($i18n->props)) ->{$tab}; $response->tab = $tab; $response->sidebar = (object) [ "creatorSidebarRenderer" => (object) [ "sections" => [ (object) [ "creatorSidebarSectionRenderer" => (object) [ "title" => (object) [ "simpleText" => $i18n->title ], "targetId" => "rehike-config", "isSelected" => true, "items" => [] ] ] ] ] ]; if ($status != null) { $response->alerts = []; switch ($status) { case "success": $response->alerts[] = new MAlert([ "type" => MAlert::TypeSuccess, "text" => $i18n->saveChangesSuccess ]); break; case "failure": $response->alerts[] = new MAlert([ "type" => MAlert::TypeError, "text" => $i18n->saveChangesFailure ]); break; } } foreach ($tabs as $name => $text) { $response->sidebar->creatorSidebarRenderer->sections[0] ->creatorSidebarSectionRenderer->items[] = self::buildCreatorSidebarItem( $text, "/rehike/config/{$name}", ($name == $tab) ); } $response->content = (object) [ "title" => $tabs->{$tab}, "contents" => [] ]; $contents = &$response->content->contents; foreach (ConfigManager::getConfig() ->{$tab} as $option => $value) { switch (ConfigManager::getConfigType("{$tab}.{$option}")) { case "bool": $contents[] = (object) [ "checkboxRenderer" => (object) [ "title" => $props->{$option} ->title ?? null, "subtitle" => $props->{$option} ->subtitle ?? null, "checked" => $value ? true : false, "name" => "$tab.$option", ] ]; break; case "enum": $values = []; $selectedValue = null; foreach ($props->{$option} ->values as $name => $text) { $values[] = (object) [ "text" => $text, "value" => $name, "selected" => ($value == $name) ]; if ($value == $name) $selectedValue = $value; } $contents[] = (object) [ "selectRenderer" => (object) [ "label" => $props->{$option} ->title, "name" => "$tab.$option", "values" => $values, "selectedValue" => $selectedValue ] ]; break; } } $response->content->saveButton = new MButton([ "style" => "STYLE_PRIMARY", "text" => (object) [ "simpleText" => $i18n->saveChanges ], "type" => "submit", "class" => ["rehike-config-save-button"], "isDisabled" => true ]); return $response; } public static function buildCreatorSidebarItem($title, $href, $selected = false) { return (object) [ "creatorSidebarItemRenderer" => (object) [ "title" => (object) [ "simpleText" => $title ] , "navigationEndpoint" => NavigationEndpoint::createEndpoint($href), "isSelected" => $selected ] ]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Rehike\Security; use Rehike\Model\Common\MButton; use Rehike\Model\Traits\Runs; /** * Informs the user of a security vulnerability via a lightbox. * * Examples include having Apache installed as a service, which involves * misconfiguration of middleware and which can be exploited by malware. * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Maintainers */ class SecurityLightbox { use Runs; public string $title; public array $message = []; public MButton $learnMoreButton; public MButton $dismissButton; public MButton $moreOptionsButton; public MButton $doNotShowAgainButton; public function __construct() { $this->title = "Security warning"; $this->createMessage(); $this->learnMoreButton = new MButton([ "style" => "STYLE_PRIMARY", "targetId" => "rehike-security-notice-learn-more-button", "customAttributes" => [ "target" => "_blank" ], "text" => (object)[ "runs" => [ (object)[ "text" => "Learn more" ] ] ], "navigationEndpoint" => (object)[ "commandMetadata" => (object)[ "webCommandMetadata" => (object)[ "url" => "https://github.com/Rehike/Rehike/wiki/Running-Apache-as-user-on-Windows" ] ] ] ]); $this->dismissButton = new MButton([ "style" => "STYLE_DEFAULT", "targetId" => "rehike-security-notice-dismiss-button", "text" => (object)[ "runs" => [ (object)[ "text" => "Dismiss" ] ] ] ]); $this->moreOptionsButton = new MButton([ "style" => "STYLE_OPACITY", "targetId" => "rehike-security-notice-more-options-button", "text" => (object)[ "runs" => [ (object)[ "text" => "More options" ] ] ], "hasArrow" => true ]); $this->doNotShowAgainButton = new MButton([ "style" => "STYLE_DESTRUCTIVE", "targetId" => "rehike-security-notice-ignore-button", "text" => (object)[ "runs" => [ (object)[ "text" => "Do not show this again" ] ] ] ]); } private function createMessage(): void { $this->message[] = $this->createRun( "Rehike is running as SYSTEM. This can create a security " . "vulnerability, and it is recommended that you reconfigure " . "Apache to run as your own account. " ); // $this->message[] = $this->createRun( // "Learn more.", // "https://github.com/Rehike/Rehike/wiki/Running-Apache-as-user-on-Windows" // ); } private function createDismissButton(): MButton { $button = new MButton([ "style" => "STYLE_DEFAULT", "id" => "rehike-security-notice-dismiss-button" ]); return $button; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Traits; /** * A common Runs trait that can be implemented and used * by all models. * * @author Taniko Yamamoto <[email protected]> * @author The Rehike Maintainers */ trait Runs { /** * Create a run. */ public function createRun($text, $href = null) { return (object)([ "text" => $text ] + ((null != $href) ? [ "navigationEndpoint" => (object)[ "commandMetadata" => (object)[ "webCommandMetadata" => (object)[ "url" => $href ] ] ] ] : [])); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Traits; /** * A common NavigationEndpoint trait that can be implemented and used * by all models. * * @author Aubrey Pankow <[email protected]> * @author The Rehike Maintainers */ class NavigationEndpoint { public static function createEndpoint($url) { return (object) [ "commandMetadata" => (object) [ "webCommandMetadata" => (object) [ "url" => $url ] ] ]; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Appbar; class MAppbarNavItem { public $title; public $href; public $status = self::StatusUnselected; const StatusUnselected = 0; const StatusPartiallySelected = 1; const StatusSelected = 2; public function __construct($title, $href, $status = self::StatusUnselected) { $this->title = $title; $this->href = $href; $this->status = $status; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Appbar; class MAppbarNav { public $items; public $owner = null; public function addItem($title, $href, $status) { $this->items[] = new MAppbarNavItem($title, $href, $status); } public function addOwner($title, $href, $thumbnail) { $this->owner = new MAppbarNavOwner($title, $href, $thumbnail); } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }
<?php namespace Rehike\Model\Appbar; class MAppbarNavOwner { public $title; public $href; public $thumbnail; public function __construct($title, $href, $thumbnail) { $this->title = $title; $this->href = $href; $this->thumbnail = $thumbnail; } }
{ "repo_name": "Rehike/Rehike", "stars": "81", "repo_language": "PHP", "file_name": "config.php", "mime_type": "text/x-php" }