Example #1
0
 function select()
 {
     JRequest::setVar('layout', 'select');
     return parent::display();
 }
Example #2
0
            Route::get('/image/test', 'FileController@test');
            Route::get('/slug/test', function () {
                $phrases = ['', 'and', 'this is a normal test', 'this is a really really really long test because it\'s amazing and great and am i at 50 YET???'];
                foreach ($phrases as $phrase) {
                    echo '<p>' . $phrase . ' becomes <em>' . Slug::make($phrase, ['', 'normal-test', 'normal-test-1']) . '</em></p>';
                }
            });
            Route::get('/slug/object/{object_id}', function ($object_id) {
                $object = DB::table(DB_OBJECTS)->find($object_id);
                Slug::setForObject($object);
                die('object was ' . $object->name);
            });
            Route::get('cleanup', function () {
                FieldController::cleanup();
                FileController::findOrphans();
                FileController::cleanup();
            });
            # Complex instance routing, optionally with linked_id for related objects
            Route::get('/{object_name}/delete/{instance_id}', 'InstanceController@delete');
            Route::get('/{object_name}', 'InstanceController@index');
            Route::get('/{object_name}/export', 'InstanceController@export');
            Route::get('/{object_name}/create/{linked_id?}', 'InstanceController@create');
            Route::post('/{object_name}/reorder', 'InstanceController@reorder');
            Route::post('/{object_name}/{linked_id?}', 'InstanceController@store');
            Route::get('/{object_name}/{instance_id}/{linked_id?}', 'InstanceController@edit');
            Route::put('/{object_name}/{instance_id}/{linked_id?}', 'InstanceController@update');
            Route::delete('/{object_name}/{instance_id}', 'InstanceController@destroy');
        });
    }
});
Route::filter('user', function () {
Example #3
0
    public static function ShowPdf($doc_id,$mode)
    {
        //mode 1- old style output
        //     2 - new style output


        $url = '/documents/getdocumentfile?doc_id='.$doc_id;
        /*$baseUrl = Yii::app()->baseUrl;
        $cs = Yii::app()->getClientScript();
        $cs->registerScriptFile($baseUrl.'/protected/views/filemodification.pdfjs.webvie.js');
        $cs->registerCssFile($baseUrl.'/css/yourcss.css');*/

        if ($mode==2) {
            $result = renderPartial('application.views.filemodification.viewer',array(
                    '$url'=>$url
                ),true
            );
        }

        if ($mode==1) {


            $mime_type = Images::model()->findByAttributes(array(
                'Document_ID'=>$doc_id
            ))->Mime_Type;


            $result = FileController::renderPartial('application.views.filemodification.iframe',array(
                    'mime_type'=>$mime_type,
                    'doc_id'=>$doc_id
                ),true
            );
        }
        return $result;
    }
 public function update($object_name, $instance_id, $linked_id = false)
 {
     $object = DB::table(DB_OBJECTS)->where('name', $object_name)->first();
     $fields = DB::table(DB_FIELDS)->where('object_id', $object->id)->where('visibility', '<>', 'hidden')->get();
     //metadata
     $updates = array('updated_at' => new DateTime(), 'updated_by' => Auth::user()->id);
     //run loop through the fields
     foreach ($fields as $field) {
         if ($field->type == 'checkboxes') {
             # Figure out schema
             $object_column = self::getKey($object->name);
             $remote_column = self::getKey($field->related_object_id);
             # Clear old values
             DB::table($field->name)->where($object_column, $instance_id)->delete();
             # Loop through and save all the checkboxes
             if (Input::has($field->name)) {
                 foreach (Input::get($field->name) as $related_id) {
                     DB::table($field->name)->insert(array($object_column => $instance_id, $remote_column => $related_id));
                 }
             }
         } elseif ($field->type == 'images') {
             # Unset any old file associations (will get cleaned up after this loop)
             DB::table(DB_FILES)->where('field_id', $field->id)->where('instance_id', $instance_id)->update(array('instance_id' => null));
             # Create new associations
             $file_ids = explode(',', Input::get($field->name));
             $precedence = 0;
             foreach ($file_ids as $file_id) {
                 DB::table(DB_FILES)->where('id', $file_id)->update(array('instance_id' => $instance_id, 'precedence' => ++$precedence));
             }
         } else {
             if ($field->type == 'image') {
                 # Unset any old file associations (will get cleaned up after this loop)
                 DB::table(DB_FILES)->where('field_id', $field->id)->where('instance_id', $instance_id)->update(array('instance_id' => null));
                 # Capture the uploaded file by setting the reverse-lookup
                 DB::table(DB_FILES)->where('id', Input::get($field->name))->update(array('instance_id' => $instance_id));
             }
             $updates[$field->name] = self::sanitize($field);
         }
     }
     //slug
     if (!empty($object->url)) {
         $uniques = DB::table($object->name)->where('id', '<>', $instance_id)->lists('slug');
         $updates['slug'] = Slug::make(Input::get('slug'), $uniques);
     }
     /* //todo manage a redirect table if client demand warrants it
     		$old_slug = DB::table($object->name)->find($instance_id)->pluck('slug');
     		if ($updates['slug'] != $old_slug) {
     		}*/
     //run update
     DB::table($object->name)->where('id', $instance_id)->update($updates);
     //clean up abandoned files
     FileController::cleanup();
     //update object meta
     DB::table(DB_OBJECTS)->where('id', $object->id)->update(['count' => DB::table($object->name)->whereNull('deleted_at')->count(), 'updated_at' => new DateTime(), 'updated_by' => Auth::user()->id]);
     return Redirect::to(Input::get('return_to'));
 }
 public static function launchCourse($idCourse, $token, $page)
 {
     $app = \Slim\Slim::getInstance();
     if (!Course::find($idCourse)) {
         $app->halt("404");
     }
     $auth = Auth_Token::where('token', '=', $token)->first();
     if (!$auth || Enrollment::where('user_id', '=', $auth->user_id)->where('course_id', '=', $idCourse)->count() == 0) {
         $app->response->headers->set('Content-Type', 'text/html');
         $app->render('course_launch_401.php');
         $app->stop();
     }
     FileController::readCourse($idCourse, $page);
 }
Example #6
0
<?php

/**
 * Created by PhpStorm.
 * User: meathill
 * Date: 15/3/20
 * Time: 下午3:56
 */
require dirname(__FILE__) . '/../vendor/autoload.php';
$file = new FileController();
$ipa_path = dirname(__FILE__) . '/../public/upload/ad_url/201503/0_1c539fb91a887cc7b4772e6ea31a1efe.ipa';
$plist_path = dirname(__FILE__) . '/Info.plist';
//$result = $file->parse_ipa($ipa_path, 'test');
$result = $file->parse_plist($plist_path);
echo '======== start ========';
var_dump($result);
echo '======== ok ========';
 public static function download($idUser, $idCourse)
 {
     $app = \Slim\Slim::getInstance();
     if (!Course::find($idCourse)) {
         $app->response->setStatus(404);
         return json_encode("Course not found");
     }
     if (!Enrollment::where('user_id', '=', $idUser)->where('course_id', '=', $idCourse)->count()) {
         $app->response->setStatus(401);
         return json_encode("You have to enroll this course first.");
     }
     FileController::downloadCourse($idCourse);
 }