| [ Index ] |
PHP Cross Reference of PageLines Framework |
[Summary view] [Print] [Text view]
1 <?php 2 3 4 class PageLinesDashboard { 5 6 7 function __contruct(){} 8 9 function draw(){ 10 11 // Updates Dashboard 12 13 $dashboards = ''; 14 15 $updates = $this->get_updates(); 16 17 $args = array( 18 'title' => __( 'Your Available Updates', 'pagelines' ), 19 'data' => $updates, 20 'icon' => PL_ADMIN_ICONS . '/download.png', 21 'excerpt-trim' => 0 22 ); 23 24 if ( ! EXTEND_NETWORK ) 25 $dashboards = $this->dashboard_pane('updates', $args); 26 27 // PageLines Blog Dashboard 28 29 $args = array( 30 'title' => __( 'News from the PageLines Blog', 'pagelines' ), 31 'data' => PageLines_RSS::get_dash_rss( array( 'feed' => 'http://www.pagelines.com/feed/' ) ), 32 'classes' => 'news-dash pl-dash-half pl-dash-space', 33 'icon' => PL_ADMIN_ICONS . '/welcome.png', 34 'footer' => sprintf('Visit <a href="%s">PageLines Blog</a>', 'http://www.pagelines.com/blog') 35 ); 36 37 $dashboards .= $this->dashboard_pane('news', $args); 38 39 // Latest from the Community 40 $args = array( 41 'title' => __( 'From the Community', 'pagelines' ), 42 'data' => PageLines_RSS::get_dash_rss( array( 'feed' => 'http://www.pagelines.com/type/link/feed/', 'community' => true ) ), 43 'classes' => 'news-dash pl-dash-half', 44 'icon' => PL_ADMIN_ICONS . '/users.png', 45 'footer' => sprintf('<a href="%s">Submit</a> a community article', 'mailto:hello@pagelines.com') 46 ); 47 48 $dashboards .= $this->dashboard_pane('community', $args); 49 50 // PageLines Store Latest Dash 51 52 $args = array( 53 'title' => __( 'Updates on PageLines Store', 'pagelines' ), 54 'data' => PageLines_RSS::get_dash_rss(), 55 'classes' => 'news-dash pl-dash-half pl-dash-space', 56 'icon' => PL_ADMIN_ICONS . '/store.png', 57 'footer' => sprintf('Visit <a href="%s">PageLines Store</a>', 'http://www.pagelines.com/store/') 58 ); 59 60 $dashboards .= $this->dashboard_pane('store', $args); 61 62 // PageLines Plus 63 $args = array( 64 'title' => __( 'Latest Extensions', 'pagelines' ), 65 'data' => PageLines_RSS::get_dash_rss( array( 'feed' => 'http://api.pagelines.com/rss/plus.php' ) ), 66 'classes' => 'news-dash pl-dash-half', 67 'icon' => PL_ADMIN_ICONS . '/plusbtn.png', 68 'footer' => sprintf('Visit <a href="%s">Plus Overview</a>', 'http://www.pagelines.com/plus/') 69 ); 70 71 $dashboards .= $this->dashboard_pane('extensions', $args); 72 73 74 return $this->dashboard_wrap($dashboards); 75 76 } 77 78 function dashboard_wrap( $dashboards ){ 79 80 return sprintf('<div class="pl-dashboards fix">%s</div>', $dashboards); 81 82 } 83 84 function wrap_dashboard_pane($id, $args = array()){ 85 return sprintf('<div class="pl-dashboards fix">%s</div>', $this->dashboard_pane( $id, $args )); 86 } 87 88 89 function dashboard_pane( $id, $args = array() ){ 90 91 $defaults = array( 92 'title' => __( 'Dashboard', 'pagelines' ), 93 'icon' => PL_ADMIN_ICONS.'/pin.png', 94 'classes' => '', 95 'data' => array(), 96 'data-format' => 'array', 97 'excerpt-trim' => 10, 98 'footer' => false 99 ); 100 101 $a = wp_parse_args($args, $defaults); 102 103 ob_start() 104 ?> 105 <div id="<?php echo 'pl-dash-'.$id;?>" class="pl-dash <?php echo $a['classes'];?>"> 106 <div class="pl-dash-pad"> 107 <div class="pl-vignette"> 108 <h2 class="dash-title"><?php printf('<img src="%s"/> %s', $a['icon'], $a['title']); ?></h2> 109 <?php 110 echo $this->dashboard_stories( $a ); 111 echo $this->dashboard_footer( $a ); 112 ?> 113 </div> 114 </div> 115 </div> 116 <?php 117 118 return ob_get_clean(); 119 120 } 121 122 function dashboard_stories( $args = array() ){ 123 124 if($args['data-format'] == 'array') 125 return $this->stories_array_format($args); 126 127 128 } 129 130 function dashboard_footer( $args = array() ){ 131 132 if($args['footer']) 133 printf('<div class="dash-foot"><div class="dash-foot-pad">%s</div></div>', $args['footer']); 134 135 } 136 137 function stories_array_format($args){ 138 139 $btn_text = (isset($args['btn-text'])) ? $args['btn-text'] : false; 140 $align_class = (isset($args['align']) && $args['align'] == 'right') ? 'rtimg' : ''; 141 $target = (isset($args['target']) && $args['target'] == 'new') ? 'target="_blank"' : ''; 142 143 $format = (isset($args['format']) && $args['format'] == 'plus-extensions') ? 'plus' : 'standard'; 144 145 ob_start(); 146 147 $count = 1; 148 foreach($args['data'] as $id => $story){ 149 150 $image = (isset($story['img'])) ? $story['img'] : false; 151 $tag = (isset($story['tag'])) ? $story['tag'] : false; 152 $link = (isset($story['link'])) ? $story['link'] : false; 153 154 $btn_text = (isset($story['btn-text'])) ? $story['btn-text'] : $btn_text; 155 156 $tag_class = (isset($story['tag-class'])) ? $story['tag-class'] : ''; 157 158 $alt = ($count % 2 == 0) ? 'alt-story' : ''; 159 160 $excerpt = ( isset( $story['text'] ) ) ? $story['text'] : ''; 161 162 $title = ( isset( $story['link'] ) ) ? sprintf( '<a href="%s">%s</a>', $story['link'], $story['title'] ) : $story['title']; 163 164 165 if ( $excerpt ) 166 $excerpt = (!$args['excerpt-trim']) ? $story['text'] : custom_trim_excerpt($story['text'], $args['excerpt-trim']); 167 ?> 168 <div class="pl-dashboard-story media <?php echo $alt;?> dashpane"> 169 <div class="dashpane-pad fix"> 170 <?php 171 if($tag) { 172 173 $button = $this->get_upgrade_button( $story['data'] ); 174 175 printf('<div class="img %s">%s</div>', $align_class, $button ); 176 177 178 179 } elseif($btn_text){ 180 181 printf('<div class="img %s"><a class="extend_button" href="%s" %s>%s</a></div>', $align_class, $link, $target, $btn_text); 182 183 } elseif($image) 184 printf('<div class="img %s img-frame"><img src="%s" /></div>', $align_class, $image); 185 186 ?> 187 <div class="bd"> 188 <h4 class="story-title"><?php echo $title; ?></h4> 189 <p><?php echo $excerpt; ?></p> 190 <?php 191 $this->special_buttons($args, $story); 192 193 ?> 194 195 </div> 196 </div> 197 </div> 198 199 <?php 200 $count++; 201 } 202 203 return ob_get_clean(); 204 } 205 206 function special_buttons($args, $story){ 207 208 if(!isset($args['format']) || $args['format'] != 'plus-extensions') 209 return; 210 211 if( pagelines_check_credentials() && ! pagelines_check_credentials( 'plus' ) ): 212 213 printf( '<a href="%s" class="extend_button">%s →</a>', pl_get_plus_link(), __( 'Get PageLines Plus', 'pagelines' ) ); 214 215 endif; 216 217 if(!pagelines_check_credentials()): 218 printf( '<a href="%s" class="extend_button discrete">%s →</a>', admin_url( PL_ACCOUNT_URL ), __( 'Have Plus? Login', 'pagelines' ) ); 219 endif; 220 221 if( pagelines_check_credentials( 'plus' ) ): 222 223 echo $this->get_upgrade_button( $story, 'install_rss' ); 224 225 endif; 226 227 228 } 229 230 231 function get_upgrade_button( $data, $mode = 'upgrade' ) { 232 233 global $extension_control; 234 $button = ''; 235 if ( 'install_rss' === $mode && ! EXTEND_NETWORK ): 236 237 // we need to convert a rss url into hardcore API data 238 $slug = basename( $data['link'] ); 239 $type = basename( str_replace( $slug, '', $data['link'] ) ); 240 241 $data = $extension_control->get_latest_cached( $type ); 242 243 $data = $data->$slug; 244 245 $type = rtrim( $type, 's' ); 246 247 $file = ( 'section' === $type ) ? $data->class : $slug; 248 249 // if section or plugin, convert to array for is_installed(). 250 if( 'section' === $type || 'plugin' === $type ) 251 $ext = json_decode(json_encode($data), true); 252 else 253 $ext = $data; 254 255 if ( $extension_control->is_installed( $type, $slug, $ext, 'dash_rss' ) ) 256 $o = array( 257 'mode' => 'installed', 258 'condition' => true, 259 'text' => __( 'Installed', 'pagelines' ) 260 ); 261 else 262 $o = array( 263 'mode' => 'install', 264 'case' => sprintf( '%s_install', $type ), 265 'text' => 'Install Now', 266 'type' => $type, 267 'file' => $file, 268 'path' => $slug, 269 'dtext' => sprintf( 'Installing %s', $data->name ), 270 'condition' => 1, 271 'dashboard' => true 272 ); 273 274 $button = $extension_control->ui->extend_button( $slug, $o); 275 endif; 276 277 if ( 'upgrade' === $mode ) : 278 $type = rtrim( $data->type, 's' ); 279 280 $file = ( 'section' === $type ) ? $data->class : $data->slug; 281 282 $o = array( 283 'mode' => 'upgrade', 284 'case' => sprintf( '%s_upgrade', $type ), 285 'text' => 'Upgrade Now', 286 'type' => $type, 287 'file' => $data->slug, 288 'path' => $file, 289 'dtext' => sprintf( 'Upgrading to version %s', $data->version ), 290 'condition' => 1, 291 'dashboard' => true 292 ); 293 294 $button = $extension_control->ui->extend_button( $data->slug, $o); 295 endif; 296 297 return $button; 298 } 299 300 function stories_remote_url_format(){ 301 302 } 303 304 function get_updates() { 305 306 $default['story0'] = array( 307 'title' => __( "No new updates available.", 'pagelines' ), 308 'text' => false 309 ); 310 311 if ( EXTEND_NETWORK ) 312 return $default; 313 314 $updates = json_decode( get_theme_mod( 'pending_updates' ) ); 315 316 if( !is_object( $updates ) ) 317 return $default; 318 319 $data = array(); 320 $a = 0; 321 foreach( $updates as $key => $update ) { 322 323 $data["story$a"] = array( 324 325 'title' => $update->name, 326 'text' => $update->changelog, 327 'tag' => $update->type, 328 'data' => $update 329 330 ); 331 $a++; 332 } 333 if( empty( $data ) ) 334 return $default; 335 return $data; 336 } 337 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat Apr 6 23:00:27 2013 | Cross-referenced by PHPXref 0.7.1 |