return new CActiveDataProvider('Item', array(
'criteria' => $criteria,
....................................................................
'pagination' => array(
'pageSize' => 10,
'pageVar' => 'item_page',
),
.....................................................................
'sort' => array(
'defaultOrder' => 't.sortorder DESC, t.title ASC',
'attributes' => array(
'title' => array(
'asc' => 't.title',
'desc' => 't.title DESC',
),
'price' => array(
'asc' => 't.price',
'desc' => 't.price DESC',
),
),
),
));
var file = dataURLtoBlob(canvas.toDataURL());
var img = blobToFile(file, "image.png");
var data = new FormData();
data.append(0, img, "image.png");
data.append( 'my_file_upload', 1 );
$.ajax({
url : './submit.php',
type : 'POST',
data : data,
cache : false,
dataType : 'json',
processData : false,
contentType : false,
success : function( respond, status, jqXHR ){
if( typeof respond.error === 'undefined' ){
console.log('ОТВЕТ: ' + respond.files)
}
else {
console.log('ОШИБКА: ' + respond.error);
}
},
error: function( jqXHR, status, errorThrown ){
console.log( 'ОШИБКА AJAX запроса: ' + status, jqXHR );
}
});
});
function blobToFile(theBlob, fileName){
theBlob.lastModifiedDate = new Date();
theBlob.name = fileName;
return theBlob;
}
if( isset( $_POST['my_file_upload'] ) ){
// указать путь к wp-load.php - он у меня такой
require( dirname(__FILE__) . '/../../../../wp-load.php' );
$wordpress_upload_dir = wp_upload_dir();
$files = $_FILES;
$done_files = array();
foreach( $files as $file ) {
$new_file_path = $wordpress_upload_dir['path'] . '/' . $file['name'];
$new_file_mime = mime_content_type( $file['tmp_name'] );
if( move_uploaded_file( $file['tmp_name'], $new_file_path ) ) {
$upload_id = wp_insert_attachment( array(
'guid' => $new_file_path,
'post_mime_type' => $new_file_mime,
'post_title' => preg_replace( '/\.[^.]+$/', '', $file['name'] ),
'post_content' => '',
'post_status' => 'inherit'
), $new_file_path );
require_once( ABSPATH . 'wp-admin/includes/image.php' );
wp_update_attachment_metadata( $upload_id, wp_generate_attachment_metadata( $upload_id, $new_file_path ) );
$done_files[] = $new_file_path;
}
}
$data = $done_files ? array('files' => $done_files ) : array('error' => 'Ошибка загрузки файлов.');
die( json_encode( $data ) );
}
?>
var n = 31;
var cans = [10, 15].sort(); // по возрастанию
var res = {};
while (n > 0) {
let count = -1;
for (let c in cans) {
if (cans[c] < n) {
count++;
}
else {
count++;
break;
}
}
if (count < 0)
continue;
if (!res[ cans[count] ]) res[ cans[count] ] = 0;
res[ cans[count] ]++;
n -= cans[count];
}
If ActivePage.Layers("curves").Shapes.Count <> 0 Then
ActivePage.Layers("curves").Shapes.All.CreateSelection
ActiveSelection.Fill.ApplyNoFill
Dim s2 As Shape
Set s2 = ActiveSelection.Combine
s2.Style.StringAssign "{""outline"":{""width"":""762""}}"
ActivePage.Layers("curves").Shapes.All.CreateSelection
ActiveSelection.Outline.Color = CreateRGBColor(255, 0, 0)
s2.BreakApartEx
End If
// chatId - это Id, которое мы получаем способом выше
telegramApi.getHistory({
id: chatId,
type: 'user' // Вот этот параметр
}).then(function(e) {
// Делаем что-то с сообщениями
})
{"error":"invalid_scope","error_description":"standalone applications should use blank.html as redirect_uri to access messages"}
try {
var doc = app.activeDocument;
var maxW = 100, maxH = 100, s = 1;
for( var i = 0 ; i < doc.artLayers.length; i++ ) {
var activeLayer = doc.artLayers.getByName( doc.artLayers[ i ].name );
var orUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PERCENT;
var w = parseFloat(activeLayer.bounds[2]) - parseFloat(activeLayer.bounds[0]);
var h = parseFloat(activeLayer.bounds[3]) - parseFloat(activeLayer.bounds[1]);
if (w > h) {
s = maxW / w * 100;
} else {
s = maxH / h * 100;
}
activeLayer.resize( s, s, AnchorPosition.TOPLEFT );
app.preferences.rulerUnits = Units.PIXELS;
w = parseFloat(activeLayer.bounds[2]) - parseFloat(activeLayer.bounds[0]);
h = parseFloat(activeLayer.bounds[3]) - parseFloat(activeLayer.bounds[1]);
var dX = (doc.width - w) / 2 - parseFloat(activeLayer.bounds[0]);
var dY = (doc.height - h) / 2 - parseFloat(activeLayer.bounds[1]);
activeLayer.translate(dX, dY);
app.preferences.rulerUnits = orUnits;
}
}
catch( e ) {
//alert( e );
}