Added : Dashboard functions
Fixed : get_image_file function @functions_photos.php Added : Add new collection page Updated : Photo uploader, to select collection if encoded collection_id is provided
This commit is contained in:
parent
43cbad25be
commit
1c86ef7006
10 changed files with 309 additions and 10 deletions
231
upload/includes/functions_dashboard.php
Normal file
231
upload/includes/functions_dashboard.php
Normal file
|
@ -0,0 +1,231 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Function loads default levels of important for dashboard
|
||||
* widgets. Uses <em>dashboard_widget_importance</em> filter
|
||||
* @return array
|
||||
*/
|
||||
function get_dashboard_widget_importance() {
|
||||
$importance = array( 'highest', 'high', 'normal', 'low', 'lowest' );
|
||||
$importance = apply_filters( $importance, 'dashboard_widget_importance' );
|
||||
return $importance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the provided importance exists or not.
|
||||
* @param string $importance
|
||||
* @return string
|
||||
*/
|
||||
function _check_widget_importance( $importance ) {
|
||||
$default = get_dashboard_widget_importance();
|
||||
return ( !in_array( $importance, $default) ? 'normal' : $importance );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all dashboards
|
||||
* @global object $Cbucket
|
||||
* @return array
|
||||
*/
|
||||
function get_dashboards() {
|
||||
global $Cbucket;
|
||||
return $Cbucket->dashboards;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return dashboard for specific place
|
||||
* @param sring $place
|
||||
* @return array
|
||||
*/
|
||||
function get_dashboard( $place ) {
|
||||
$dashboards = get_dashboards();
|
||||
return $dashboards[ $place ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns value to dashboards variable
|
||||
* @global object $Cbucket
|
||||
* @param array $dashboards
|
||||
* @return array
|
||||
*/
|
||||
function set_dashboards( $dashboards ) {
|
||||
global $Cbucket;
|
||||
return $Cbucket->dashboards = $dashboards;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns dashborad widget to dashboard for specifc place and importance
|
||||
* @global object $Cbucket
|
||||
* @param type $place
|
||||
* @param array $dashboard_widget
|
||||
* @param string $importace
|
||||
* @return array
|
||||
*/
|
||||
function set_dashboard( $place, $dashboard_widget, $importance = 'normal' ) {
|
||||
global $Cbucket;
|
||||
$id = key( $dashboard_widget );
|
||||
return $Cbucket->dashboards[ $place ][ $importance ][ $id ] = $dashboard_widget[ $id ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets position of last widget in dashboard for specific place and importance
|
||||
* @param string $place
|
||||
* @param string $importance
|
||||
* @param array $dashboard
|
||||
* @return boolean
|
||||
*/
|
||||
function get_last_dashboard_widget_position( $place, $importance = 'normal', $dashboard = null ) {
|
||||
if ( is_null( $dashboard ) ) {
|
||||
$dashboard = get_dashboard( $place );
|
||||
}
|
||||
|
||||
if ( $dashboard ) {
|
||||
$widgets = $dashboard[ $importance ];
|
||||
if ( $widgets ) {
|
||||
$last_widget = end ( $widgets );
|
||||
return $last_widget[ 'position' ];
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if widgets or not
|
||||
* @param string $id
|
||||
* @param string $place
|
||||
* @param string $importance
|
||||
* @return boolean
|
||||
*/
|
||||
function dashboard_widget_exists( $id, $place, $importance = 'normal' ) {
|
||||
$dashboards = get_dashboards();
|
||||
if ( isset( $dashboards[ $place ][ $importance ][ $id ] ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds widget in dashboard for specific place and importance
|
||||
* @param string $place
|
||||
* @param string $id
|
||||
* @param string $name
|
||||
* @param string $display_callback
|
||||
* @param string $importance
|
||||
* @param string $description
|
||||
* @param string $callback
|
||||
* @return boolean
|
||||
*/
|
||||
function add_dashboard_widget( $place, $id, $name, $display_callback, $importance = 'normal', $description = null, $callback = null ) {
|
||||
if ( !dashboard_widget_exists( $id, $place, $importance ) ) {
|
||||
|
||||
if ( !function_exists( $display_callback ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$importance = _check_widget_importance( $importance );
|
||||
$position = get_last_dashboard_widget_position( $place, $importance );
|
||||
$dashboard_widget[ $id ] = array(
|
||||
'id' => $id,
|
||||
'name' => $name,
|
||||
'display_callback' => $display_callback,
|
||||
'importance' => $importance,
|
||||
'description' => $description,
|
||||
'position' => $position ? ( $position+1 ) : (int)1,
|
||||
'callback' => $callback
|
||||
);
|
||||
|
||||
return set_dashboard( $place, $dashboard_widget, $importance );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display dashboard for specific place. If not place is provided,
|
||||
* we'll try to look if some dashboard is registered for current
|
||||
* page using THIS_PAGE constant.
|
||||
*
|
||||
* @todo Add open close toggler, configurations for widgets
|
||||
* @param string $place
|
||||
* @return string|boolean
|
||||
*/
|
||||
function display_dashboard( $place = null ) {
|
||||
|
||||
if ( is_null( $place ) ) {
|
||||
$place = THIS_PAGE;
|
||||
}
|
||||
|
||||
$dashboard = get_dashboard( $place );
|
||||
if ( $dashboard ) {
|
||||
$output = ''; // Dashboard widgets output
|
||||
$importance = get_dashboard_widget_importance();
|
||||
|
||||
foreach ( $importance as $important ) {
|
||||
if ( isset( $dashboard[ $important ] ) ) {
|
||||
$dashboard_widgets = $dashboard[ $important ];
|
||||
$dashboard_widgets = apply_filters( $dashboard_widgets, 'dashboard_widgets' );
|
||||
$total_dashboard_widgets = count( $dashboard_widgets );
|
||||
if ( $dashboard_widgets ) {
|
||||
$output .= '<div id="'.$place.'-'.$important.'-importance" class="dashboard-widgets dashboard-widgets-'.$important.'-importance '.$place.'-widgets has-'.$total_dashboard_widgets.'-widgets" data-importance="'.$important.'" data-palce="'.$place.'">';
|
||||
foreach ( $dashboard_widgets as $dashboard_widget ) {
|
||||
$output .= '<div id="'.$dashboard_widget['id'].'-'.$dashboard_widget['importance'].'" class="dashboard-widget '.SEO( strtolower( $dashboard_widget['name'] ) ).' '.$dashboard_widget['id'].' is-'.$important.'">';
|
||||
$output .= '<h3 class="dashboard-widget-name">'.$dashboard_widget['name'].'</h3>';
|
||||
if ( $dashboard_widget['description'] ) {
|
||||
$output .= '<div class="dashboard-widget-description">'.$dashboard_widget['description'].'</div>';
|
||||
}
|
||||
$output .= '<div class="dashboard-content">';
|
||||
$output .= $dashboard_widget['display_callback'] ( $dashboard_widget );
|
||||
$output .= '</div>';
|
||||
$output .= '</div>';
|
||||
}
|
||||
$output .= '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This orders the widgets of specifc place and important according
|
||||
* to their positions.
|
||||
*
|
||||
* @todo Make positioning of widgets work
|
||||
* @param array $widgets
|
||||
* @return array
|
||||
*/
|
||||
function _order_dashboard_widgets_to_position( $widgets ) {
|
||||
|
||||
foreach ( $widgets as $widget ) {
|
||||
$tmp_arr[ $widget['position'] ] = $widget['id'];
|
||||
}
|
||||
|
||||
ksort( $tmp_arr );
|
||||
|
||||
foreach ( $tmp_arr as $tmp ) {
|
||||
$ordered_widgets[ $tmp ] = $widgets[ $tmp ];
|
||||
}
|
||||
|
||||
return $ordered_widgets;
|
||||
}
|
||||
|
||||
function setup_myaccount_dashboard() {
|
||||
add_dashboard_widget('myaccount','account_dashboard_videos','Videos','account_dashboard_videos');
|
||||
add_dashboard_widget('myaccount','account_dashboard_photos','Photos','account_dashboard_photos');
|
||||
add_dashboard_widget('myaccount','account_dashboard_messages','Messages','account_dashboard_messages', 'highest');
|
||||
}
|
||||
|
||||
function account_dashboard_videos( $widget ) {
|
||||
return $widget['name'];
|
||||
}
|
||||
|
||||
function account_dashboard_photos ( $widget ) {
|
||||
return $widget['name'];
|
||||
}
|
||||
|
||||
function account_dashboard_messages( $widget ) {
|
||||
return $widget['name'];
|
||||
}
|
||||
?>
|
|
@ -1535,7 +1535,7 @@ function get_image_file ( $params ) {
|
|||
$filename = sprintf( $file_name, "_".$size );
|
||||
$full_path = $path.$filename;
|
||||
|
||||
if ( isset( $image_details[$size] ) ) {
|
||||
{
|
||||
if ( file_exists( $full_path ) ) {
|
||||
if ( $with_path ) {
|
||||
$thumbs[] = PHOTOS_URL.'/'.$file_directory.$filename;
|
||||
|
@ -1553,7 +1553,7 @@ function get_image_file ( $params ) {
|
|||
$thumbs[] = sprintf( $file_name, "");
|
||||
}
|
||||
}
|
||||
|
||||
//pr ( $thumbs, true );
|
||||
if ( !$thumbs or count($thumbs) <= 0 ) {
|
||||
$thumbs = _recheck_photo_code( $params );
|
||||
if ( !$thumbs or !is_array( $thumbs ) ) {
|
||||
|
|
|
@ -163,4 +163,7 @@ add_collection_manager_order( lang('Oldest'), tbl('collections.date_added asc')
|
|||
add_collection_manager_order( lang('Most Viewed'), tbl('collections.views desc') );
|
||||
add_collection_manager_order( lang('Most Photos'), tbl('collections.total_objects desc') );
|
||||
add_collection_manager_order( lang('Last Updated'), tbl('collections.last_updated desc') );
|
||||
|
||||
register_filter( 'dashboard_widgets', '_order_dashboard_widgets_to_position' );
|
||||
|
||||
?>
|
||||
|
|
|
@ -79,11 +79,15 @@ switch($mode)
|
|||
|
||||
if(isset($_POST['add_collection']))
|
||||
{
|
||||
$cbcollection->create_collection($_POST);
|
||||
|
||||
if(!error()) $_POST = '';
|
||||
$collection_id = $cbcollection->create_collection($_POST);
|
||||
$collection['collection_id'] = $collection_id;
|
||||
|
||||
if ( !error() ) {
|
||||
redirect_to( $cbphoto->photo_links( $collection, 'upload_more' ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
subtitle(lang("create_collection"));
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -61,7 +61,7 @@ How this should work
|
|||
return minutes+":"+seconds;
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
$(document).ready( function(){
|
||||
var uploader = new plupload.Uploader({
|
||||
runtimes : 'html5,flash',
|
||||
browse_button : 'plupload-pickfiles',
|
||||
|
@ -75,7 +75,10 @@ How this should work
|
|||
]
|
||||
});
|
||||
|
||||
|
||||
if ( window['js_{$js_var}'] ) {
|
||||
var collection_id = window['js_{$js_var}'];
|
||||
}
|
||||
|
||||
uploader.init();
|
||||
|
||||
var overall_template = $('#upload-overall-template-item').find('.upload-overall').clone();
|
||||
|
@ -140,6 +143,10 @@ How this should work
|
|||
form_template.find('input[name=photo_title]').val( name_without_extension );
|
||||
form_template.find('textarea[name=photo_description]').val( name_without_extension );
|
||||
|
||||
if ( collection_id ) {
|
||||
form_template.find('select[name=collection_id]').val( collection_id );
|
||||
}
|
||||
|
||||
$('#upload-form-container').append( form_template );
|
||||
/* ------- UPLOAD FORM BLOCK TEMPLATE END ------- */
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ define("PARENT_PAGE",'home');
|
|||
require 'includes/config.inc.php';
|
||||
$userquery->logincheck();
|
||||
|
||||
setup_myaccount_dashboard();
|
||||
|
||||
subtitle(lang("my_account"));
|
||||
assign('user',$userquery->get_user_details(userid()));
|
||||
template_files('myaccount.html');
|
||||
|
|
|
@ -17,8 +17,26 @@ subtitle(lang('photos_upload'));
|
|||
|
||||
if(isset($_GET['collection']))
|
||||
{
|
||||
$c = $cbphoto->decode_key($_GET['collection']);
|
||||
assign('c',$cbphoto->collection->get_collection($c));
|
||||
$cid = $cbphoto->decode_key($_GET['collection']);
|
||||
$collection = $cbphoto->collection->get_collection( $cid );
|
||||
if ( $collection ) {
|
||||
$js_var = sha1( $_GET['collection'].RandomString( 8 ) );
|
||||
$start = rand( 5, 10 );
|
||||
$js_var = substr( $js_var, $start, 8 );
|
||||
assign( 'collection', $collection );
|
||||
assign( 'js_var', $js_var );
|
||||
|
||||
function _add_collection_id_js() {
|
||||
global $collection, $js_var;
|
||||
$output = '<script type="text/javascript">';
|
||||
$output .= 'var js_'.$js_var.' = '.$collection['collection_id'].';';
|
||||
$output .= '</script>';
|
||||
|
||||
echo $output;
|
||||
}
|
||||
|
||||
register_anchor_function( '_add_collection_id_js', 'cb_head' );
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['EnterInfo']))
|
||||
|
|
|
@ -2,6 +2,34 @@
|
|||
|
||||
|
||||
<div class="account-right">
|
||||
|
||||
{if $mode == 'add_new'}
|
||||
<div class="account-heading">
|
||||
<h2>{lang code='Add new collection'}</h2>
|
||||
<div class="manager-list">
|
||||
<form action="" method="post" class="form-horizontal">
|
||||
<fieldset>
|
||||
<legend>{lang code='Required fields'}</legend>
|
||||
{foreach from=$fields item=field}
|
||||
{include_template_file file='common/form_field.html' field=$field}
|
||||
{/foreach}
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>{lang code='Other options'}</legend>
|
||||
{foreach from=$other_fields item=field}
|
||||
{include_template_file file='common/form_field.html' field=$field}
|
||||
{/foreach}
|
||||
</fieldset>
|
||||
|
||||
<div class="form-actions">
|
||||
<button name="add_collection" id="add_collection" class="btn btn-primary">{lang code='Add new collection'}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{if $mode == "manage" || $mode == ""}
|
||||
<div class="account-heading">
|
||||
<h2>{lang code='Manage Collections'} ({$total_collections})</h2>
|
||||
|
@ -160,7 +188,7 @@
|
|||
{foreach $objs as $avatar}
|
||||
<div class="manage-collection-items">
|
||||
<div class="manage-collection-item">
|
||||
<img src="{get_photo details=$avatar size='m'}" class="manage-collection-item-thumb" />
|
||||
<img src="{get_photo details=$avatar size='m'}" class="manage-collection-item-thumb cbv3-center-image" />
|
||||
<div class="black-gradient absolute bottom manage-collection-item-details">
|
||||
<h4><a href="{$cbphoto->collection->collection_links($collection,'vc')}">{$collection.collection_name}</a></h4>
|
||||
<div class="pull-left">{$avatar.date_added|date_format}</div>
|
||||
|
|
|
@ -1 +1,6 @@
|
|||
{include_template_file file="blocks/account_left.html"}
|
||||
<div class="account-right">
|
||||
<div class="account-dashboard-container clearfix">
|
||||
{display_dashboard()}
|
||||
</div>
|
||||
</div>
|
|
@ -15,6 +15,7 @@
|
|||
@import url("channels.css");
|
||||
@import url("videos.css");
|
||||
@import url("search.css");
|
||||
@import url("account.css");
|
||||
|
||||
/**bootstrap icon fix
|
||||
----------------------------------------
|
||||
|
|
Loading…
Add table
Reference in a new issue