Exemplo n.º 1
0
<?php

$FieldTag = new PerchXMLTag('<perch:content id="image" type="image" disable-asset-panel="true" app-mode="true" detect-type="true" />');
$FieldTag->set('input_id', 'image');
$Assets = new PerchAssets_Assets();
$Tags = new PerchAssets_Tags();
$Form = new PerchForm('edit');
$message = false;
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    $assetID = (int) $_GET['id'];
    $Asset = $Assets->find($assetID);
    if ($Asset) {
        if (!$Asset->is_image()) {
            $FieldTag->set('type', 'file');
        }
    }
} else {
    if (!$CurrentUser->has_priv('assets.create')) {
        PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/assets/');
    }
    $assetID = false;
    $Asset = false;
}
$Form = new PerchForm('edit');
$req = array();
$req['resourceTitle'] = "Required";
$Form->set_required($req);
if ($Form->posted() && $Form->validate()) {
    /*
    if (isset($_POST['image_remove']) && $_POST['image_remove']=='1') {
        $Asset->delete();
Exemplo n.º 2
0
<?php

$Assets = new PerchAssets_Assets();
$Assets->reindex();
Exemplo n.º 3
0
<?php

include realpath(__DIR__ . '/../../..') . '/inc/pre_config.php';
include realpath(__DIR__ . '/../../../..') . '/config/config.php';
include PERCH_CORE . '/inc/loader.php';
$Perch = PerchAdmin::fetch();
include PERCH_CORE . '/inc/auth_light.php';
$Perch->page_title = PerchLang::get('Manage Assets');
include __DIR__ . '/../PerchAssets_Asset.class.php';
include __DIR__ . '/../PerchAssets_Assets.class.php';
include __DIR__ . '/../PerchAssets_Tags.class.php';
include __DIR__ . '/../PerchAssets_Tag.class.php';
$Paging = new PerchPaging();
$Paging->set_per_page(32);
$Assets = new PerchAssets_Assets();
$view = 'grid';
$filters = array();
if (isset($_GET['filter']) && $_GET['filter'] == 'new') {
    $filters['new'] = true;
}
if (isset($_GET['app']) && $_GET['app'] != '') {
    $filters['app'] = $_GET['app'];
}
if (isset($_GET['type']) && $_GET['type'] != '') {
    $filters['type'] = $_GET['type'];
}
if (isset($_GET['bucket']) && $_GET['bucket'] != '') {
    $filters['bucket'] = $_GET['bucket'];
}
if (isset($_GET['date']) && $_GET['date'] != '') {
    $filters['date'] = $_GET['date'];
Exemplo n.º 4
0
     if (isset($_POST['quality'])) {
         $quality = (int) $_POST['quality'];
     }
     $Tag->set('quality', $quality);
     $sharpen = false;
     if (isset($_POST['sharpen'])) {
         $sharpen = (int) $_POST['sharpen'];
     }
     $Tag->set('sharpen', $sharpen);
     $density = 1;
     if (isset($_POST['density'])) {
         $density = (int) $_POST['density'];
     }
     $Tag->set('density', $density);
 }
 $Assets = new PerchAssets_Assets();
 $message = false;
 $assetID = false;
 $Asset = false;
 $Form = new PerchForm('edit');
 $Resources = new PerchResources();
 $data = array();
 $FieldType = PerchFieldTypes::get($Tag->type(), $Form, $Tag, array($Tag), 'markitup');
 $var = $FieldType->get_raw();
 if (PerchUtil::count($var)) {
     $ids = $Resources->get_logged_ids();
     $Resources->mark_group_as_library($ids);
     $assetID = $ids[0];
     $Asset = $Assets->find($assetID);
     if (isset($_POST['miu_image_upload_title']) && $_POST['miu_image_upload_title'] != '') {
         $Asset->update(array('resourceTitle' => $_POST['miu_image_upload_title']));
Exemplo n.º 5
0
<?php

include realpath(__DIR__ . '/../../..') . '/inc/pre_config.php';
include realpath(__DIR__ . '/../../../..') . '/config/config.php';
include PERCH_CORE . '/inc/loader.php';
$Perch = PerchAdmin::fetch();
include PERCH_CORE . '/inc/auth_light.php';
$Perch->page_title = PerchLang::get('Manage Assets');
include __DIR__ . '/../PerchAssets_Asset.class.php';
include __DIR__ . '/../PerchAssets_Assets.class.php';
include __DIR__ . '/../PerchAssets_Tags.class.php';
include __DIR__ . '/../PerchAssets_Tag.class.php';
$Paging = new PerchPaging();
$Paging->set_per_page(24);
$Assets = new PerchAssets_Assets();
if (isset($_GET['q']) && $_GET['q'] != '') {
    $term = $_GET['q'];
} else {
    die;
}
$assets = $Assets->search($term);
$out = array();
if (PerchUtil::count($assets)) {
    foreach ($assets as $Asset) {
        $out[] = $Asset->to_api_array();
    }
}
echo PerchUtil::json_safe_encode(array('assets' => $out));
 public function render_inputs($details = array())
 {
     $Perch = Perch::fetch();
     $Bucket = PerchResourceBuckets::get($this->Tag->bucket());
     if (!class_exists('PerchAssets_Assets', false)) {
         include_once PERCH_CORE . '/apps/assets/PerchAssets_Assets.class.php';
         include_once PERCH_CORE . '/apps/assets/PerchAssets_Asset.class.php';
     }
     $s = $this->Form->image($this->Tag->input_id());
     $s .= $this->Form->hidden($this->Tag->input_id() . '_field', '1');
     $assetID = false;
     $asset_field = $this->Tag->input_id() . '_assetID';
     if (isset($details[$this->Tag->input_id()]['assetID'])) {
         $assetID = $details[$this->Tag->input_id()]['assetID'];
     }
     $s .= $this->Form->hidden($asset_field, $assetID);
     $Bucket->initialise();
     if (!$Bucket->ready_to_write()) {
         $s .= $this->Form->hint(PerchLang::get('Your resources folder is not writable. Make this folder (') . PerchUtil::html($Bucket->get_web_path()) . PerchLang::get(') writable to upload files.'), 'error');
     }
     if (isset($details[$this->Tag->input_id()]) && $details[$this->Tag->input_id()] != '') {
         $json = $details[$this->Tag->input_id()];
         //PerchUtil::debug($json);
         if (isset($json['bucket'])) {
             $Bucket = PerchResourceBuckets::get($json['bucket']);
         }
         if (is_array($json) && isset($json['path'])) {
             $path = $json['path'];
         } else {
             if (!is_array($json)) {
                 $path = $json;
             } else {
                 $path = '--false--';
             }
         }
         $file_path = PerchUtil::file_path($Bucket->get_file_path() . '/' . $path);
         if (!file_exists($file_path) && $assetID) {
             $Assets = new PerchAssets_Assets();
             $Asset = $Assets->find($assetID);
             if (is_object($Asset)) {
                 $file_path = $Asset->file_path();
             }
         } else {
             $Asset = false;
         }
         if (isset($json['sizes']['thumb'])) {
             $image_src = $json['sizes']['thumb']['path'];
             $image_w = $json['sizes']['thumb']['w'];
             $image_h = $json['sizes']['thumb']['h'];
             $image_path = PerchUtil::file_path($Bucket->get_file_path() . '/' . $image_src);
             $thumb = true;
         } else {
             $thumb = false;
         }
         if (file_exists($file_path)) {
             $s .= '<div class="asset-badge" data-for="' . $asset_field . '">';
             $type = PerchAssets_Asset::get_type_from_filename($path);
             $s .= '<div class="asset-badge-thumb asset-icon icon asset-' . $type . '">';
             if ($thumb) {
                 $s .= '<img src="' . PerchUtil::html($Bucket->get_web_path() . '/' . $image_src) . '" width="' . $image_w . '" height="' . $image_h . '" alt="Preview" />';
             }
             $s .= '</div><div class="asset-badge-meta">';
             if (!$this->Tag->is_set('app_mode')) {
                 $s .= '<div class="asset-badge-remove">';
                 $s .= $this->Form->label($this->Tag->input_id() . '_remove', PerchLang::get('Remove'), 'inline') . ' ';
                 $s .= $this->Form->checkbox($this->Tag->input_id() . '_remove', '1', 0);
                 $s .= '</div>';
             }
             if ($json) {
                 $s .= '<ul class="meta">';
                 $s .= '<li class="title">';
                 if ($Asset) {
                     $s .= '<a href="' . $Asset->web_path() . '">';
                 }
                 $s .= isset($json['title']) ? $json['title'] : str_replace(PERCH_RESPATH . '/', '', $path);
                 if ($Asset) {
                     $s .= '</a>';
                 }
                 $s .= '</li>';
                 if (isset($json['mime'])) {
                     $s .= '<li>' . ucfirst(str_replace('/', ' / ', $json['mime'])) . '</li>';
                 }
                 $size = floatval($json['size']);
                 if ($size < 1048576) {
                     $size = round($size / 1024, 0) . 'KB';
                 } else {
                     $size = round($size / 1024 / 1024, 0) . 'MB';
                 }
                 $s .= '<li>' . $size . '</li>';
                 $s .= '</ul>';
             }
             $s .= '</div>';
             $s .= '</div>';
         }
     } else {
         $s .= '<div class="asset-badge hidden" data-for="' . $asset_field . '">';
         $s .= '</div>';
     }
     if (isset($file_path) && file_exists($file_path)) {
         $s .= $this->Form->hidden($this->Tag->input_id() . '_populated', '1');
     }
     $type = 'doc';
     if ($this->Tag->file_type()) {
         $type = $this->Tag->file_type();
     }
     $s .= ' <span class="ft-choose-asset ft-file ' . ($this->Tag->disable_asset_panel() ? ' assets-disabled' : '') . '" data-type="' . $type . '" data-field="' . $asset_field . '" data-bucket="' . PerchUtil::html($Bucket->get_name(), true) . '" data-input="' . $this->Tag->input_id() . '"></span>';
     return $s;
 }
 public function get_fieldtype_profile()
 {
     $out = array();
     $Assets = new PerchAssets_Assets();
     $Thumb = $Assets->get_thumb($this->id());
     $out['assetID'] = $this->id();
     $out['title'] = $this->resourceTitle();
     $out['bucket'] = $this->resourceBucket();
     $out['sizes'] = array();
     $out['size'] = $this->resourceFileSize();
     if ($Thumb) {
         $out['sizes']['thumb'] = array();
         $out['sizes']['thumb']['w'] = $Thumb->resourceWidth();
         $out['sizes']['thumb']['h'] = $Thumb->resourceHeight();
         $out['sizes']['thumb']['web_path'] = $Thumb->web_path();
         $out['sizes']['thumb']['path'] = $Thumb->resourceFile();
     }
     return $out;
 }