source: trunk/www.guidonia.net/wp/wp-content/plugins/tubepress/classes/org/tubepress/options/reference/SimpleOptionsReference.class.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 9.4 KB
Line 
1<?php
2/**
3 * Copyright 2006, 2007, 2008, 2009 Eric D. Hough (http://ehough.com)
4 *
5 * This file is part of TubePress (http://tubepress.org)
6 *
7 * TubePress is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * TubePress is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with TubePress. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22function_exists('tubepress_load_classes')
23 || require(dirname(__FILE__) . '/../../../../tubepress_classloader.php');
24tubepress_load_classes(array('org_tubepress_options_reference_OptionsReference',
25 'org_tubepress_options_Type',
26 'org_tubepress_options_category_Embedded',
27 'org_tubepress_options_category_Gallery',
28 'org_tubepress_options_category_Advanced',
29 'org_tubepress_options_category_Feed',
30 'org_tubepress_options_category_Widget',
31 'org_tubepress_options_category_Display',
32 'org_tubepress_options_category_Meta'));
33
34/**
35 * Simple implementation of options reference
36 *
37 */
38class org_tubepress_options_reference_SimpleOptionsReference implements org_tubepress_options_reference_OptionsReference
39{
40
41 private $_options = array(
42 org_tubepress_options_Type::COLOR => array(
43 org_tubepress_options_category_Embedded::PLAYER_COLOR => "999999",
44 org_tubepress_options_category_Embedded::PLAYER_HIGHLIGHT => "FFFFFF"
45 ),
46 org_tubepress_options_Type::MODE => array(
47 org_tubepress_options_category_Gallery::MODE => "recently_featured"
48 ),
49 org_tubepress_options_Type::TEXT => array(
50 org_tubepress_options_category_Advanced::DATEFORMAT => "M j, Y",
51 org_tubepress_options_category_Advanced::KEYWORD => "tubepress",
52 org_tubepress_options_category_Gallery::FAVORITES_VALUE => "mrdeathgod",
53 org_tubepress_options_category_Gallery::PLAYLIST_VALUE => "D2B04665B213AE35",
54 org_tubepress_options_category_Gallery::TAG_VALUE => "stewart daily show",
55 org_tubepress_options_category_Gallery::USER_VALUE => "3hough",
56 org_tubepress_options_category_Feed::CLIENT_KEY => "ytapi-EricHough-TubePress-ki6oq9tc-0",
57 org_tubepress_options_category_Feed::DEV_KEY => "AI39si5uUzupiQW9bpzGqZRrhvqF3vBgRqL-I_28G1zWozmdNJlskzMDQEhpZ-l2RqGf_6CNWooL96oJZRrqKo-eJ9QO_QppMg",
58 org_tubepress_options_category_Widget::TITLE => "TubePress",
59 org_tubepress_options_category_Widget::TAGSTRING => "[tubepress thumbHeight='105', thumbWidth='135']"
60 ),
61 org_tubepress_options_Type::BOOL => array(
62 org_tubepress_options_category_Advanced::DEBUG_ON => true,
63 org_tubepress_options_category_Advanced::NOFOLLOW_LINKS => true,
64 org_tubepress_options_category_Advanced::RANDOM_THUMBS => true,
65 org_tubepress_options_category_Display::RELATIVE_DATES => false,
66 org_tubepress_options_category_Display::PAGINATE_ABOVE => true,
67 org_tubepress_options_category_Display::PAGINATE_BELOW => true,
68 org_tubepress_options_category_Embedded::AUTOPLAY => false,
69 org_tubepress_options_category_Embedded::BORDER => false,
70 org_tubepress_options_category_Embedded::GENIE => false,
71 org_tubepress_options_category_Embedded::LOOP => false,
72 org_tubepress_options_category_Embedded::SHOW_INFO => false,
73 org_tubepress_options_category_Embedded::SHOW_RELATED => true,
74 org_tubepress_options_category_Embedded::FULLSCREEN => true,
75 org_tubepress_options_category_Meta::AUTHOR => false,
76 org_tubepress_options_category_Meta::CATEGORY => false,
77 org_tubepress_options_category_Meta::DESCRIPTION => false,
78 org_tubepress_options_category_Meta::ID => false,
79 org_tubepress_options_category_Meta::LENGTH => true,
80 org_tubepress_options_category_Meta::RATING => false,
81 org_tubepress_options_category_Meta::RATINGS => false,
82 org_tubepress_options_category_Meta::TAGS => false,
83 org_tubepress_options_category_Meta::TITLE => true,
84 org_tubepress_options_category_Meta::UPLOADED => false,
85 org_tubepress_options_category_Meta::URL => false,
86 org_tubepress_options_category_Meta::VIEWS => true,
87 org_tubepress_options_category_Feed::CACHE_ENABLED => true,
88 org_tubepress_options_category_Feed::EMBEDDABLE_ONLY => true
89 ),
90 org_tubepress_options_Type::INTEGRAL => array(
91 org_tubepress_options_category_Display::DESC_LIMIT => 80,
92 org_tubepress_options_category_Display::RESULTS_PER_PAGE => 20,
93 org_tubepress_options_category_Display::THUMB_HEIGHT => 90,
94 org_tubepress_options_category_Display::THUMB_WIDTH => 120,
95 org_tubepress_options_category_Embedded::EMBEDDED_HEIGHT => 350,
96 org_tubepress_options_category_Embedded::EMBEDDED_WIDTH => 425
97 ),
98 org_tubepress_options_Type::TIME_FRAME => array(
99 org_tubepress_options_category_Gallery::MOST_VIEWED_VALUE => "today",
100 org_tubepress_options_category_Gallery::TOP_RATED_VALUE => "today"
101 ),
102 org_tubepress_options_Type::ORDER => array(
103 org_tubepress_options_category_Display::ORDER_BY => "viewCount",
104 ),
105 org_tubepress_options_Type::PLAYER => array(
106 org_tubepress_options_category_Display::CURRENT_PLAYER_NAME => "normal",
107 ),
108 org_tubepress_options_Type::QUALITY => array(
109 org_tubepress_options_category_Embedded::QUALITY => "normal"
110 ),
111 org_tubepress_options_Type::SAFE_SEARCH => array(
112 org_tubepress_options_category_Feed::FILTER => "moderate"
113 ),
114 org_tubepress_options_Type::PLAYER_IMPL => array(
115 org_tubepress_options_category_Embedded::PLAYER_IMPL => "youtube"
116 )
117 );
118
119 function getAllOptionNames()
120 {
121 $results = array();
122 foreach ($this->_options as $optionGroup) {
123 $results = array_merge($results, array_keys($optionGroup));
124 }
125 return $results;
126 }
127
128 function getCategory($optionName)
129 {
130 foreach ($this->getOptionCategoryNames() as $optionCategoryName) {
131 if (in_array($optionName, $this->getOptionNamesForCategory($optionCategoryName))) {
132 return $optionCategoryName;
133 }
134 }
135 }
136
137 function getDefaultValue($optionName)
138 {
139 foreach ($this->_options as $optionType) {
140 if (array_key_exists($optionName, $optionType)) {
141 return $optionType[$optionName];
142 }
143 }
144 return NULL;
145 }
146
147 function getOptionCategoryNames()
148 {
149 return array("gallery", "display", "embedded", "meta", "feed", "advanced", "widget");
150 }
151
152 function getOptionNamesForCategory($category)
153 {
154 $className = "org_tubepress_options_category_" . ucwords($category);
155 return $this->_getConstantsForClass($className);
156 }
157
158 function getValidEnumValues($optionType)
159 {
160 switch ($optionType) {
161 case org_tubepress_options_Type::PLAYER:
162 return array("normal", "popup","shadowbox",'jqmodal', "youtube");
163 case org_tubepress_options_Type::ORDER:
164 return array("relevance", "viewCount", "rating", "updated", "random");
165 case org_tubepress_options_Type::QUALITY:
166 return array("normal", "high", "higher", "highest");
167 case org_tubepress_options_Type::MODE:
168 return array('favorites', 'playlist', 'tag', 'user', "recently_featured", "mobile", "most_discussed",
169 "most_linked", "most_recent", "most_responded", "most_viewed",
170 "top_rated");
171 case org_tubepress_options_Type::SAFE_SEARCH:
172 return array("none", "moderate", "strict");
173 case org_tubepress_options_Type::PLAYER_IMPL:
174 return array("youtube", "longtail");
175 }
176 return array("today", "this_week", "this_month", "all_time");
177 }
178
179 function isOptionName($candidateOptionName)
180 {
181 foreach ($this->_options as $optionType) {
182 if (array_key_exists($candidateOptionName, $optionType)) {
183 return true;
184 }
185 }
186 return false;
187 }
188
189 function getType($optionName)
190 {
191 foreach ($this->_options as $optionType => $values) {
192 if (array_key_exists($optionName, $values)) {
193 return $optionType;
194 }
195 }
196 }
197
198 private function _getConstantsForClass($className)
199 {
200 $ref = new ReflectionClass($className);
201 return array_values($ref->getConstants());
202 }
203}
Note: See TracBrowser for help on using the repository browser.