idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
49,300
public function actionIgnore ( $ id = null ) { if ( Podium :: getInstance ( ) -> user -> isGuest ) { return $ this -> redirect ( [ 'forum/index' ] ) ; } $ model = User :: find ( ) -> where ( [ 'and' , [ 'id' => ( int ) $ id ] , [ '!=' , 'status' , User :: STATUS_REGISTERED ] ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ model ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find Member with this ID.' ) ) ; return $ this -> redirect ( [ 'members/index' ] ) ; } $ logged = User :: loggedId ( ) ; if ( $ model -> id == $ logged ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! You can not ignore your own account.' ) ) ; return $ this -> redirect ( [ 'members/view' , 'id' => $ model -> id , 'slug' => $ model -> podiumSlug ] ) ; } if ( $ model -> id == User :: ROLE_ADMIN ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! You can not ignore Administrator.' ) ) ; return $ this -> redirect ( [ 'members/view' , 'id' => $ model -> id , 'slug' => $ model -> podiumSlug ] ) ; } if ( $ model -> updateIgnore ( $ logged ) ) { if ( $ model -> isIgnoredBy ( $ logged ) ) { $ this -> success ( Yii :: t ( 'podium/flash' , 'User is now ignored.' ) ) ; } else { $ this -> success ( Yii :: t ( 'podium/flash' , 'User is not ignored anymore.' ) ) ; } } else { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was some error while performing this action.' ) ) ; } return $ this -> redirect ( [ 'members/view' , 'id' => $ model -> id , 'slug' => $ model -> podiumSlug ] ) ; }
Ignoring the user of given ID .
49,301
public function actionView ( $ id = null , $ slug = null ) { $ model = User :: find ( ) -> where ( [ 'and' , [ 'id' => $ id ] , [ '!=' , 'status' , User :: STATUS_REGISTERED ] , [ 'or' , [ 'slug' => $ slug ] , [ 'slug' => '' ] , [ 'slug' => null ] , ] ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ model ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find Member with this ID.' ) ) ; return $ this -> redirect ( [ 'members/index' ] ) ; } return $ this -> render ( 'view' , [ 'model' => $ model ] ) ; }
Viewing profile of user of given ID and slug .
49,302
public function actionFriend ( $ id = null ) { if ( Podium :: getInstance ( ) -> user -> isGuest ) { return $ this -> redirect ( [ 'forum/index' ] ) ; } $ model = User :: find ( ) -> where ( [ 'and' , [ 'id' => $ id ] , [ '!=' , 'status' , User :: STATUS_REGISTERED ] ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ model ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find Member with this ID.' ) ) ; return $ this -> redirect ( [ 'members/index' ] ) ; } $ logged = User :: loggedId ( ) ; if ( $ model -> id == $ logged ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! You can not befriend your own account.' ) ) ; return $ this -> redirect ( [ 'members/view' , 'id' => $ model -> id , 'slug' => $ model -> podiumSlug ] ) ; } if ( $ model -> updateFriend ( $ logged ) ) { if ( $ model -> isBefriendedBy ( $ logged ) ) { $ this -> success ( Yii :: t ( 'podium/flash' , 'User is your friend now.' ) ) ; } else { $ this -> success ( Yii :: t ( 'podium/flash' , 'User is not your friend anymore.' ) ) ; } } else { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was some error while performing this action.' ) ) ; } return $ this -> redirect ( [ 'members/view' , 'id' => $ model -> id , 'slug' => $ model -> podiumSlug ] ) ; }
Adding or removing user as a friend .
49,303
public function getThread ( $ cid , $ fid , $ id , $ slug ) { if ( $ this -> _thread === null ) { $ this -> _thread = ( new ThreadVerifier ( [ 'categoryId' => $ cid , 'forumId' => $ fid , 'threadId' => $ id , 'threadSlug' => $ slug ] ) ) -> verify ( ) ; } return $ this -> _thread ; }
Returns thread .
49,304
public function search ( $ params ) { $ query = static :: find ( ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query ] ) ; $ dataProvider -> sort -> defaultOrder = [ 'id' => SORT_DESC ] ; $ dataProvider -> pagination -> pageSize = Yii :: $ app -> session -> get ( 'per-page' , 20 ) ; if ( ! ( $ this -> load ( $ params ) && $ this -> validate ( ) ) ) { return $ dataProvider ; } $ query -> andFilterWhere ( [ 'id' => $ this -> id ] ) -> andFilterWhere ( [ 'level' => $ this -> level ] ) -> andFilterWhere ( [ 'model' => $ this -> model ] ) -> andFilterWhere ( [ 'user' => $ this -> user ] ) -> andFilterWhere ( [ 'like' , 'category' , $ this -> category ] ) -> andFilterWhere ( [ 'like' , 'ip' , $ this -> ip ] ) -> andFilterWhere ( [ 'like' , 'message' , $ this -> message ] ) ; return $ dataProvider ; }
Searches for logs .
49,305
public function countPercent ( $ currentStep , $ maxStep ) { $ percent = $ maxStep ? round ( 100 * $ currentStep / $ maxStep ) : 0 ; if ( $ percent > 100 ) { $ percent = 100 ; } if ( $ percent == 100 && $ currentStep != $ maxStep ) { $ percent = 99 ; } if ( $ percent == 100 ) { $ this -> clearCache ( ) ; } return $ percent ; }
Returns percent . Clears cache at 100 .
49,306
public function afterSave ( $ insert , $ changedAttributes ) { try { if ( $ insert ) { $ this -> insertWords ( ) ; } else { $ this -> updateWords ( ) ; } } catch ( Exception $ e ) { throw $ e ; } parent :: afterSave ( $ insert , $ changedAttributes ) ; }
Updates post tag words .
49,307
protected function prepareWords ( ) { $ cleanHtml = HtmlPurifier :: process ( trim ( $ this -> content ) ) ; $ purged = preg_replace ( '/<[^>]+>/' , ' ' , $ cleanHtml ) ; $ wordsRaw = array_unique ( preg_split ( '/[\s,\.\n]+/' , $ purged ) ) ; $ allWords = [ ] ; foreach ( $ wordsRaw as $ word ) { if ( mb_strlen ( $ word , 'UTF-8' ) > 2 && mb_strlen ( $ word , 'UTF-8' ) <= 255 ) { $ allWords [ ] = $ word ; } } return $ allWords ; }
Prepares tag words .
49,308
protected function addNewWords ( $ allWords ) { try { $ newWords = $ allWords ; $ query = ( new Query ( ) ) -> from ( Vocabulary :: tableName ( ) ) -> where ( [ 'word' => $ allWords ] ) ; foreach ( $ query -> each ( ) as $ vocabularyFound ) { if ( ( $ key = array_search ( $ vocabularyFound [ 'word' ] , $ allWords ) ) !== false ) { unset ( $ newWords [ $ key ] ) ; } } $ formatWords = [ ] ; foreach ( $ newWords as $ word ) { $ formatWords [ ] = [ $ word ] ; } if ( ! empty ( $ formatWords ) ) { if ( ! Podium :: getInstance ( ) -> db -> createCommand ( ) -> batchInsert ( Vocabulary :: tableName ( ) , [ 'word' ] , $ formatWords ) -> execute ( ) ) { throw new Exception ( 'Words saving error!' ) ; } } } catch ( Exception $ e ) { Log :: error ( $ e -> getMessage ( ) , null , __METHOD__ ) ; throw $ e ; } }
Adds new tag words .
49,309
protected function insertWords ( ) { try { $ vocabulary = [ ] ; $ allWords = $ this -> prepareWords ( ) ; $ this -> addNewWords ( $ allWords ) ; $ query = ( new Query ( ) ) -> from ( Vocabulary :: tableName ( ) ) -> where ( [ 'word' => $ allWords ] ) ; foreach ( $ query -> each ( ) as $ vocabularyNew ) { $ vocabulary [ ] = [ $ vocabularyNew [ 'id' ] , $ this -> id ] ; } if ( ! empty ( $ vocabulary ) ) { if ( ! Podium :: getInstance ( ) -> db -> createCommand ( ) -> batchInsert ( '{{%podium_vocabulary_junction}}' , [ 'word_id' , 'post_id' ] , $ vocabulary ) -> execute ( ) ) { throw new Exception ( 'Words connections saving error!' ) ; } } } catch ( Exception $ e ) { Log :: error ( $ e -> getMessage ( ) , null , __METHOD__ ) ; throw $ e ; } }
Inserts tag words .
49,310
protected function updateWords ( ) { try { $ vocabulary = [ ] ; $ allWords = $ this -> prepareWords ( ) ; $ this -> addNewWords ( $ allWords ) ; $ queryVocabulary = ( new Query ( ) ) -> from ( Vocabulary :: tableName ( ) ) -> where ( [ 'word' => $ allWords ] ) ; foreach ( $ queryVocabulary -> each ( ) as $ vocabularyNew ) { $ vocabulary [ $ vocabularyNew [ 'id' ] ] = [ $ vocabularyNew [ 'id' ] , $ this -> id ] ; } if ( ! empty ( $ vocabulary ) ) { if ( ! Podium :: getInstance ( ) -> db -> createCommand ( ) -> batchInsert ( '{{%podium_vocabulary_junction}}' , [ 'word_id' , 'post_id' ] , array_values ( $ vocabulary ) ) -> execute ( ) ) { throw new Exception ( 'Words connections saving error!' ) ; } } $ queryJunction = ( new Query ( ) ) -> from ( '{{%podium_vocabulary_junction}}' ) -> where ( [ 'post_id' => $ this -> id ] ) ; foreach ( $ queryJunction -> each ( ) as $ junk ) { if ( ! array_key_exists ( $ junk [ 'word_id' ] , $ vocabulary ) ) { if ( ! Podium :: getInstance ( ) -> db -> createCommand ( ) -> delete ( '{{%podium_vocabulary_junction}}' , [ 'id' => $ junk [ 'id' ] ] ) -> execute ( ) ) { throw new Exception ( 'Words connections deleting error!' ) ; } } } } catch ( Exception $ e ) { Log :: error ( $ e -> getMessage ( ) , null , __METHOD__ ) ; throw $ e ; } }
Updates tag words .
49,311
public function search ( $ forumId , $ threadId ) { $ dataProvider = new ActiveDataProvider ( [ 'query' => static :: find ( ) -> where ( [ 'forum_id' => $ forumId , 'thread_id' => $ threadId ] ) , 'pagination' => [ 'defaultPageSize' => 10 , 'pageSizeLimit' => false , 'forcePageParam' => false ] , ] ) ; $ dataProvider -> sort -> defaultOrder = [ 'id' => SORT_ASC ] ; return $ dataProvider ; }
Searches for posts .
49,312
public static function verify ( $ categoryId = null , $ forumId = null , $ threadId = null , $ id = null ) { if ( ! is_numeric ( $ categoryId ) || $ categoryId < 1 || ! is_numeric ( $ forumId ) || $ forumId < 1 || ! is_numeric ( $ threadId ) || $ threadId < 1 || ! is_numeric ( $ id ) || $ id < 1 ) { return null ; } return static :: find ( ) -> joinWith ( [ 'thread' , 'forum' => function ( $ query ) use ( $ categoryId ) { $ query -> joinWith ( [ 'category' ] ) -> andWhere ( [ Category :: tableName ( ) . '.id' => $ categoryId ] ) ; } ] ) -> where ( [ static :: tableName ( ) . '.id' => $ id , static :: tableName ( ) . '.thread_id' => $ threadId , static :: tableName ( ) . '.forum_id' => $ forumId , ] ) -> limit ( 1 ) -> one ( ) ; }
Returns the verified post .
49,313
public function podiumDelete ( ) { $ transaction = static :: getDb ( ) -> beginTransaction ( ) ; try { if ( ! $ this -> delete ( ) ) { throw new Exception ( 'Post deleting error!' ) ; } $ wholeThread = false ; if ( $ this -> thread -> postsCount ) { if ( ! $ this -> thread -> updateCounters ( [ 'posts' => - 1 ] ) ) { throw new Exception ( 'Thread Post counter subtracting error!' ) ; } if ( ! $ this -> forum -> updateCounters ( [ 'posts' => - 1 ] ) ) { throw new Exception ( 'Forum Post counter subtracting error!' ) ; } } else { $ wholeThread = true ; if ( ! $ this -> thread -> delete ( ) ) { throw new Exception ( 'Thread deleting error!' ) ; } if ( ! $ this -> forum -> updateCounters ( [ 'posts' => - 1 , 'threads' => - 1 ] ) ) { throw new Exception ( 'Forum Post and Thread counter subtracting error!' ) ; } } $ transaction -> commit ( ) ; PodiumCache :: clearAfter ( 'postDelete' ) ; Log :: info ( 'Post deleted' , ! empty ( $ this -> id ) ? $ this -> id : '' , __METHOD__ ) ; return true ; } catch ( Exception $ e ) { $ transaction -> rollBack ( ) ; Log :: error ( $ e -> getMessage ( ) , null , __METHOD__ ) ; } return false ; }
Performs post delete with parent forum and thread counters update .
49,314
public function podiumEdit ( $ isFirstPost = false ) { $ transaction = static :: getDb ( ) -> beginTransaction ( ) ; try { $ this -> edited = 1 ; $ this -> touch ( 'edited_at' ) ; if ( ! $ this -> save ( ) ) { throw new Exception ( 'Post saving error!' ) ; } if ( $ isFirstPost ) { $ this -> thread -> name = $ this -> topic ; if ( ! $ this -> thread -> save ( ) ) { throw new Exception ( 'Thread saving error!' ) ; } } $ this -> markSeen ( ) ; $ this -> thread -> touch ( 'edited_post_at' ) ; $ transaction -> commit ( ) ; Log :: info ( 'Post updated' , $ this -> id , __METHOD__ ) ; return true ; } catch ( Exception $ e ) { $ transaction -> rollBack ( ) ; Log :: error ( $ e -> getMessage ( ) , null , __METHOD__ ) ; } return false ; }
Performs post update with parent thread topic update in case of first post in thread .
49,315
public function podiumNew ( $ previous = null ) { $ transaction = static :: getDb ( ) -> beginTransaction ( ) ; try { $ id = null ; $ loggedId = User :: loggedId ( ) ; $ sameAuthor = ! empty ( $ previous -> author_id ) && $ previous -> author_id == $ loggedId ; if ( $ sameAuthor && Podium :: getInstance ( ) -> podiumConfig -> get ( 'merge_posts' ) ) { $ separator = '<hr>' ; if ( Podium :: getInstance ( ) -> podiumConfig -> get ( 'use_wysiwyg' ) == '0' ) { $ separator = "\n\n---\n" ; } $ previous -> content .= $ separator . $ this -> content ; $ previous -> edited = 1 ; $ previous -> touch ( 'edited_at' ) ; if ( ! $ previous -> save ( ) ) { throw new Exception ( 'Previous Post saving error!' ) ; } $ previous -> markSeen ( false ) ; $ previous -> thread -> touch ( 'edited_post_at' ) ; $ id = $ previous -> id ; $ thread = $ previous -> thread ; } else { if ( ! $ this -> save ( ) ) { throw new Exception ( 'Post saving error!' ) ; } $ this -> markSeen ( ! $ sameAuthor ) ; if ( ! $ this -> forum -> updateCounters ( [ 'posts' => 1 ] ) ) { throw new Exception ( 'Forum Post counter adding error!' ) ; } if ( ! $ this -> thread -> updateCounters ( [ 'posts' => 1 ] ) ) { throw new Exception ( 'Thread Post counter adding error!' ) ; } $ this -> thread -> touch ( 'new_post_at' ) ; $ this -> thread -> touch ( 'edited_post_at' ) ; $ id = $ this -> id ; $ thread = $ this -> thread ; } if ( empty ( $ id ) ) { throw new Exception ( 'Saved Post ID missing' ) ; } Subscription :: notify ( $ thread -> id ) ; if ( $ this -> subscribe && ! $ thread -> subscription ) { $ subscription = new Subscription ( ) ; $ subscription -> user_id = $ loggedId ; $ subscription -> thread_id = $ thread -> id ; $ subscription -> post_seen = Subscription :: POST_SEEN ; if ( ! $ subscription -> save ( ) ) { throw new Exception ( 'Subscription saving error!' ) ; } } $ transaction -> commit ( ) ; PodiumCache :: clearAfter ( 'newPost' ) ; Log :: info ( 'Post added' , $ id , __METHOD__ ) ; return true ; } catch ( Exception $ e ) { $ transaction -> rollBack ( ) ; Log :: error ( $ e -> getMessage ( ) , null , __METHOD__ ) ; } return false ; }
Performs new post creation and subscription . Depending on the settings previous post can be merged .
49,316
public function podiumThumb ( $ up = true , $ count = 0 ) { $ transaction = static :: getDb ( ) -> beginTransaction ( ) ; try { $ loggedId = User :: loggedId ( ) ; if ( $ this -> thumb ) { if ( $ this -> thumb -> thumb == 1 && ! $ up ) { $ this -> thumb -> thumb = - 1 ; if ( ! $ this -> thumb -> save ( ) ) { throw new Exception ( 'Thumb saving error!' ) ; } if ( ! $ this -> updateCounters ( [ 'likes' => - 1 , 'dislikes' => 1 ] ) ) { throw new Exception ( 'Thumb counters saving error!' ) ; } } elseif ( $ this -> thumb -> thumb == - 1 && $ up ) { $ this -> thumb -> thumb = 1 ; if ( ! $ this -> thumb -> save ( ) ) { throw new Exception ( 'Thumb saving error!' ) ; } if ( ! $ this -> updateCounters ( [ 'likes' => 1 , 'dislikes' => - 1 ] ) ) { throw new Exception ( 'Thumb counters saving error!' ) ; } } } else { $ postThumb = new PostThumb ( ) ; $ postThumb -> post_id = $ this -> id ; $ postThumb -> user_id = $ loggedId ; $ postThumb -> thumb = $ up ? 1 : - 1 ; if ( ! $ postThumb -> save ( ) ) { throw new Exception ( 'PostThumb saving error!' ) ; } if ( $ postThumb -> thumb ) { if ( ! $ this -> updateCounters ( [ 'likes' => 1 ] ) ) { throw new Exception ( 'Thumb counters saving error!' ) ; } } else { if ( ! $ this -> updateCounters ( [ 'dislikes' => 1 ] ) ) { throw new Exception ( 'Thumb counters saving error!' ) ; } } } if ( $ count == 0 ) { Podium :: getInstance ( ) -> podiumCache -> set ( 'user.votes.' . $ loggedId , [ 'count' => 1 , 'expire' => time ( ) + 3600 ] ) ; } else { Podium :: getInstance ( ) -> podiumCache -> setElement ( 'user.votes.' . $ loggedId , 'count' , $ count + 1 ) ; } $ transaction -> commit ( ) ; return true ; } catch ( Exception $ e ) { $ transaction -> rollBack ( ) ; Log :: error ( $ e -> getMessage ( ) , null , __METHOD__ ) ; } return false ; }
Performs vote processing .
49,317
public static function adminCategoriesPrepareContent ( $ category ) { $ actions = [ ] ; $ actions [ ] = Html :: button ( Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-eye-' . ( $ category -> visible ? 'open' : 'close' ) ] ) , [ 'class' => 'btn btn-xs text-muted' , 'data-toggle' => 'tooltip' , 'data-placement' => 'top' , 'title' => $ category -> visible ? Yii :: t ( 'podium/view' , 'Category visible for guests' ) : Yii :: t ( 'podium/view' , 'Category hidden for guests' ) ] ) ; $ actions [ ] = Html :: a ( Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-list' ] ) . ' ' . Yii :: t ( 'podium/view' , 'List Forums' ) , [ 'admin/forums' , 'cid' => $ category -> id ] , [ 'class' => 'btn btn-default btn-xs' ] ) ; $ actions [ ] = Html :: a ( Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-plus-sign' ] ) . ' ' . Yii :: t ( 'podium/view' , 'Create new forum' ) , [ 'admin/new-forum' , 'cid' => $ category -> id ] , [ 'class' => 'btn btn-success btn-xs' ] ) ; $ actions [ ] = Html :: a ( Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-cog' ] ) , [ 'admin/edit-category' , 'id' => $ category -> id ] , [ 'class' => 'btn btn-default btn-xs' , 'data-toggle' => 'tooltip' , 'data-placement' => 'top' , 'title' => Yii :: t ( 'podium/view' , 'Edit Category' ) ] ) ; $ actions [ ] = Html :: tag ( 'span' , Html :: button ( Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-trash' ] ) , [ 'class' => 'btn btn-danger btn-xs' , 'data-url' => Url :: to ( [ 'admin/delete-category' , 'id' => $ category -> id ] ) , 'data-toggle' => 'modal' , 'data-target' => '#podiumModalDelete' ] ) , [ 'data-toggle' => 'tooltip' , 'data-placement' => 'top' , 'title' => Yii :: t ( 'podium/view' , 'Delete Category' ) ] ) ; return Html :: tag ( 'p' , implode ( ' ' , $ actions ) , [ 'class' => 'pull-right' ] ) . Html :: tag ( 'span' , Html :: encode ( $ category -> name ) , [ 'class' => 'podium-forum' , 'data-id' => $ category -> id ] ) ; }
Prepares content for categories administration .
49,318
public static function adminForumsPrepareContent ( $ forum ) { $ actions = [ ] ; $ actions [ ] = Html :: button ( Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-eye-' . ( $ forum -> visible ? 'open' : 'close' ) ] ) , [ 'class' => 'btn btn-xs text-muted' , 'data-toggle' => 'tooltip' , 'data-placement' => 'top' , 'title' => $ forum -> visible ? Yii :: t ( 'podium/view' , 'Forum visible for guests (if category is visible)' ) : Yii :: t ( 'podium/view' , 'Forum hidden for guests' ) ] ) ; $ actions [ ] = Html :: a ( Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-cog' ] ) , [ 'admin/edit-forum' , 'id' => $ forum -> id , 'cid' => $ forum -> category_id ] , [ 'class' => 'btn btn-default btn-xs' , 'data-toggle' => 'tooltip' , 'data-placement' => 'top' , 'title' => Yii :: t ( 'podium/view' , 'Edit Forum' ) ] ) ; $ actions [ ] = Html :: tag ( 'span' , Html :: button ( Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-trash' ] ) , [ 'class' => 'btn btn-danger btn-xs' , 'data-url' => Url :: to ( [ 'admin/delete-forum' , 'id' => $ forum -> id , 'cid' => $ forum -> category_id ] ) , 'data-toggle' => 'modal' , 'data-target' => '#podiumModalDelete' ] ) , [ 'data-toggle' => 'tooltip' , 'data-placement' => 'top' , 'title' => Yii :: t ( 'podium/view' , 'Delete Forum' ) ] ) ; return Html :: tag ( 'p' , implode ( ' ' , $ actions ) , [ 'class' => 'pull-right' ] ) . Html :: tag ( 'span' , Html :: encode ( $ forum -> name ) , [ 'class' => 'podium-forum' , 'data-id' => $ forum -> id , 'data-category' => $ forum -> category_id ] ) ; }
Prepares content for forums administration .
49,319
public static function podiumUserTag ( $ name , $ role , $ id = null , $ slug = null , $ simple = false ) { $ icon = Html :: tag ( 'span' , '' , [ 'class' => $ id ? 'glyphicon glyphicon-user' : 'glyphicon glyphicon-ban-circle' ] ) ; $ url = $ id ? [ 'members/view' , 'id' => $ id , 'slug' => $ slug ] : '#' ; switch ( $ role ) { case 0 : $ colourClass = 'text-muted' ; break ; case User :: ROLE_MODERATOR : $ colourClass = 'text-info' ; break ; case User :: ROLE_ADMIN : $ colourClass = 'text-danger' ; break ; case User :: ROLE_MEMBER : default : $ colourClass = 'text-warning' ; } $ encodedName = Html :: tag ( 'span' , $ icon . ' ' . ( $ id ? Html :: encode ( $ name ) : Yii :: t ( 'podium/view' , 'user deleted' ) ) , [ 'class' => $ colourClass ] ) ; if ( $ simple ) { return $ encodedName ; } return Html :: a ( $ encodedName , $ url , [ 'class' => 'btn btn-xs btn-default' , 'data-pjax' => '0' ] ) ; }
Returns user tag .
49,320
public static function prepareQuote ( $ post , $ quote = '' ) { if ( Podium :: getInstance ( ) -> podiumConfig -> get ( 'use_wysiwyg' ) == '0' ) { $ content = ! empty ( $ quote ) ? '[...] ' . HtmlPurifier :: process ( $ quote ) . ' [...]' : $ post -> content ; return '> ' . $ post -> author -> podiumTag . ' @ ' . Podium :: getInstance ( ) -> formatter -> asDatetime ( $ post -> created_at ) . "\n> " . $ content . "\n" ; } $ content = ! empty ( $ quote ) ? '[...] ' . nl2br ( HtmlPurifier :: process ( $ quote ) ) . ' [...]' : $ post -> content ; return Html :: tag ( 'blockquote' , $ post -> author -> podiumTag . ' @ ' . Podium :: getInstance ( ) -> formatter -> asDatetime ( $ post -> created_at ) . '<br>' . $ content ) . '<br>' ; }
Returns quote HTML .
49,321
public static function roleLabel ( $ role = null ) { switch ( $ role ) { case User :: ROLE_ADMIN : $ label = 'danger' ; $ name = ArrayHelper :: getValue ( User :: getRoles ( ) , $ role ) ; break ; case User :: ROLE_MODERATOR : $ label = 'info' ; $ name = ArrayHelper :: getValue ( User :: getRoles ( ) , $ role ) ; break ; default : $ label = 'warning' ; $ name = ArrayHelper :: getValue ( User :: getRoles ( ) , User :: ROLE_MEMBER ) ; } return Html :: tag ( 'span' , $ name , [ 'class' => 'label label-' . $ label ] ) ; }
Returns role label HTML .
49,322
public static function sortOrder ( $ attribute = null ) { if ( ! empty ( $ attribute ) ) { $ sort = Yii :: $ app -> request -> get ( 'sort' ) ; if ( $ sort == $ attribute ) { return ' ' . Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-sort-by-alphabet' ] ) ; } if ( $ sort == '-' . $ attribute ) { return ' ' . Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-sort-by-alphabet-alt' ] ) ; } } return null ; }
Returns sorting icon .
49,323
public static function statusLabel ( $ status = null ) { switch ( $ status ) { case User :: STATUS_ACTIVE : $ label = 'info' ; $ name = ArrayHelper :: getValue ( User :: getStatuses ( ) , $ status ) ; break ; case User :: STATUS_BANNED : $ label = 'warning' ; $ name = ArrayHelper :: getValue ( User :: getStatuses ( ) , $ status ) ; break ; default : $ label = 'default' ; $ name = ArrayHelper :: getValue ( User :: getStatuses ( ) , User :: STATUS_REGISTERED ) ; } return Html :: tag ( 'span' , $ name , [ 'class' => 'label label-' . $ label ] ) ; }
Returns User status label .
49,324
public static function timeZones ( ) { $ timeZones = [ ] ; $ timezone_identifiers = DateTimeZone :: listIdentifiers ( ) ; sort ( $ timezone_identifiers ) ; $ timeZones [ 'UTC' ] = Yii :: t ( 'podium/view' , 'default (UTC)' ) ; foreach ( $ timezone_identifiers as $ zone ) { if ( $ zone != 'UTC' ) { $ zoneName = $ zone ; $ timeForZone = new DateTime ( null , new DateTimeZone ( $ zone ) ) ; $ offset = $ timeForZone -> getOffset ( ) ; if ( is_numeric ( $ offset ) ) { $ zoneName .= ' (UTC' ; if ( $ offset != 0 ) { $ offset = $ offset / 60 / 60 ; $ offsetDisplay = floor ( $ offset ) . ':' . str_pad ( 60 * ( $ offset - floor ( $ offset ) ) , 2 , '0' , STR_PAD_LEFT ) ; $ zoneName .= ' ' . ( $ offset < 0 ? '' : '+' ) . $ offsetDisplay ; } $ zoneName .= ')' ; } $ timeZones [ $ zone ] = $ zoneName ; } } return $ timeZones ; }
Returns time zones with current offset array .
49,325
public static function compareVersions ( $ a , $ b ) { $ versionPos = max ( count ( $ a ) , count ( $ b ) ) ; while ( count ( $ a ) < $ versionPos ) { $ a [ ] = 0 ; } while ( count ( $ b ) < $ versionPos ) { $ b [ ] = 0 ; } for ( $ v = 0 ; $ v < count ( $ a ) ; $ v ++ ) { if ( ( int ) $ a [ $ v ] < ( int ) $ b [ $ v ] ) { return '<' ; } if ( ( int ) $ a [ $ v ] > ( int ) $ b [ $ v ] ) { return '>' ; } } return '=' ; }
Comparing versions .
49,326
public static function prepareDefault ( $ name ) { $ default = static :: defaultContent ( $ name ) ; if ( empty ( $ default ) ) { return false ; } $ content = new static ; $ content -> topic = $ default [ 'topic' ] ; $ content -> content = $ default [ 'content' ] ; return $ content ; }
Returns default content object .
49,327
public static function fill ( $ name ) { $ email = Content :: find ( ) -> where ( [ 'name' => $ name ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ email ) ) { $ email = Content :: prepareDefault ( $ name ) ; } return $ email ; }
Returns email content .
49,328
public function search ( ) { $ dataProvider = new ActiveDataProvider ( [ 'query' => static :: find ( ) -> where ( [ 'user_id' => User :: loggedId ( ) ] ) , 'pagination' => [ 'defaultPageSize' => 10 , 'forcePageParam' => false ] , ] ) ; $ dataProvider -> sort -> defaultOrder = [ 'post_seen' => SORT_ASC , 'id' => SORT_DESC ] ; $ dataProvider -> pagination -> pageSize = Yii :: $ app -> session -> get ( 'per-page' , 20 ) ; return $ dataProvider ; }
Searches for subscription
49,329
public function seen ( ) { $ this -> post_seen = self :: POST_SEEN ; if ( ! $ this -> save ( ) ) { return false ; } Podium :: getInstance ( ) -> podiumCache -> deleteElement ( 'user.subscriptions' , User :: loggedId ( ) ) ; return true ; }
Marks post as seen .
49,330
public function unseen ( ) { $ this -> post_seen = self :: POST_NEW ; if ( ! $ this -> save ( ) ) { return false ; } Podium :: getInstance ( ) -> podiumCache -> deleteElement ( 'user.subscriptions' , User :: loggedId ( ) ) ; return true ; }
Marks post as unseen .
49,331
public static function notify ( $ thread ) { if ( is_numeric ( $ thread ) && $ thread > 0 ) { $ forum = Podium :: getInstance ( ) -> podiumConfig -> get ( 'name' ) ; $ email = Content :: fill ( Content :: EMAIL_SUBSCRIPTION ) ; $ subs = static :: find ( ) -> where ( [ 'thread_id' => $ thread , 'post_seen' => self :: POST_SEEN ] ) ; foreach ( $ subs -> each ( ) as $ sub ) { $ sub -> post_seen = self :: POST_NEW ; if ( $ sub -> save ( ) ) { if ( $ email !== false && ! empty ( $ sub -> user -> email ) ) { if ( Email :: queue ( $ sub -> user -> email , str_replace ( '{forum}' , $ forum , $ email -> topic ) , str_replace ( '{forum}' , $ forum , str_replace ( '{link}' , Html :: a ( Url :: to ( [ 'forum/last' , 'id' => $ sub -> thread_id ] , true ) , Url :: to ( [ 'forum/last' , 'id' => $ sub -> thread_id ] , true ) ) , $ email -> content ) ) , $ sub -> user_id ) ) { Log :: info ( 'Subscription notice link queued' , $ sub -> user_id , __METHOD__ ) ; } else { Log :: error ( 'Error while queuing subscription notice link' , $ sub -> user_id , __METHOD__ ) ; } } else { Log :: warning ( 'Error while queuing subscription notice link - no email set' , $ sub -> user_id , __METHOD__ ) ; } } } } }
Prepares notification email .
49,332
public static function remove ( $ threads = [ ] ) { try { if ( ! empty ( $ threads ) ) { return Podium :: getInstance ( ) -> db -> createCommand ( ) -> delete ( Subscription :: tableName ( ) , [ 'id' => $ threads , 'user_id' => User :: loggedId ( ) ] ) -> execute ( ) ; } } catch ( Exception $ e ) { Log :: error ( $ e -> getMessage ( ) , null , __METHOD__ ) ; } return false ; }
Removes threads subscriptions of given IDs .
49,333
public static function add ( $ thread ) { if ( Podium :: getInstance ( ) -> user -> isGuest ) { return false ; } $ sub = new Subscription ( ) ; $ sub -> thread_id = $ thread ; $ sub -> user_id = User :: loggedId ( ) ; $ sub -> post_seen = self :: POST_SEEN ; return $ sub -> save ( ) ; }
Adds subscription for thread .
49,334
public function run ( ) { try { $ next = 0 ; $ newSort = - 1 ; foreach ( $ this -> query -> each ( ) as $ id => $ model ) { if ( $ next == $ this -> order ) { $ newSort = $ next ++ ; } Podium :: getInstance ( ) -> db -> createCommand ( ) -> update ( call_user_func ( [ $ this -> target , 'tableName' ] ) , [ 'sort' => $ next ] , [ 'id' => $ id ] ) -> execute ( ) ; $ next ++ ; } if ( $ newSort == - 1 ) { $ newSort = $ next ; } $ this -> target -> sort = $ newSort ; if ( ! $ this -> target -> save ( ) ) { throw new Exception ( 'Order saving error' ) ; } Log :: info ( 'Orded updated' , $ this -> target -> id , __METHOD__ ) ; return true ; } catch ( Exception $ e ) { Log :: error ( $ e -> getMessage ( ) , null , __METHOD__ ) ; } return false ; }
Runs sorter .
49,335
public function registerClientScript ( ) { $ view = $ this -> view ; CodeMirrorAsset :: register ( $ view ) ; $ js = 'var CodeMirrorLabels = { bold: "' . Yii :: t ( 'podium/view' , 'Bold' ) . '", italic: "' . Yii :: t ( 'podium/view' , 'Italic' ) . '", header: "' . Yii :: t ( 'podium/view' , 'Header' ) . '", inlinecode: "' . Yii :: t ( 'podium/view' , 'Inline code' ) . '", blockcode: "' . Yii :: t ( 'podium/view' , 'Block code' ) . '", quote: "' . Yii :: t ( 'podium/view' , 'Quote' ) . '", bulletedlist: "' . Yii :: t ( 'podium/view' , 'Bulleted list' ) . '", orderedlist: "' . Yii :: t ( 'podium/view' , 'Ordered list' ) . '", link: "' . Yii :: t ( 'podium/view' , 'Link' ) . '", image: "' . Yii :: t ( 'podium/view' , 'Image' ) . '", help: "' . Yii :: t ( 'podium/view' , 'Help' ) . '",};var CodeMirrorSet = "' . $ this -> type . '";' ; $ view -> registerJs ( $ js , View :: POS_BEGIN ) ; }
Registers widget assets . Note that CodeMirror works without jQuery .
49,336
public function danger ( $ message , $ removeAfterAccess = true ) { Yii :: $ app -> session -> addFlash ( 'danger' , $ message , $ removeAfterAccess ) ; }
Adds flash message of danger type .
49,337
public function info ( $ message , $ removeAfterAccess = true ) { Yii :: $ app -> session -> addFlash ( 'info' , $ message , $ removeAfterAccess ) ; }
Adds flash message of info type .
49,338
public function success ( $ message , $ removeAfterAccess = true ) { Yii :: $ app -> session -> addFlash ( 'success' , $ message , $ removeAfterAccess ) ; }
Adds flash message of success type .
49,339
public function warning ( $ message , $ removeAfterAccess = true ) { Yii :: $ app -> session -> addFlash ( 'warning' , $ message , $ removeAfterAccess ) ; }
Adds flash message of warning type .
49,340
public function init ( ) { parent :: init ( ) ; $ this -> denyCallback = function ( ) { Yii :: $ app -> session -> addFlash ( $ this -> type , $ this -> message , true ) ; return Yii :: $ app -> response -> redirect ( [ Podium :: getInstance ( ) -> prepareRoute ( 'account/login' ) ] ) ; } ; }
Sets deny callback .
49,341
protected function _redirect ( ServerRequest $ request , Response $ response ) { $ message = $ request -> getSession ( ) -> consume ( $ this -> _config [ 'flashKey' ] ) ; $ url = $ response -> getHeader ( 'Location' ) [ 0 ] ; $ status = $ response -> getStatusCode ( ) ; $ json = JsonEncoder :: encode ( [ 'error' => null , 'content' => null , '_message' => $ message , '_redirect' => compact ( 'url' , 'status' ) , ] , $ this -> _config [ 'jsonOptions' ] ) ; $ response = $ response -> withStatus ( 200 ) -> withoutHeader ( 'Location' ) -> withHeader ( 'Content-Type' , 'application/json; charset=' . $ response -> getCharset ( ) ) -> withStringBody ( $ json ) ; return $ response ; }
Generate a JSON response encoding the redirect
49,342
public function render ( $ view = null , $ layout = null ) { $ dataToSerialize = [ 'error' => null , 'content' => null , ] ; if ( ! empty ( $ this -> viewVars [ 'error' ] ) ) { $ view = false ; } if ( $ view !== false && ! isset ( $ this -> viewVars [ '_redirect' ] ) && $ this -> _getViewFileName ( $ view ) ) { $ dataToSerialize [ 'content' ] = parent :: render ( $ view , $ layout ) ; } $ this -> viewVars = Hash :: merge ( $ dataToSerialize , $ this -> viewVars ) ; if ( isset ( $ this -> viewVars [ '_serialize' ] ) ) { $ dataToSerialize = $ this -> _dataToSerialize ( $ this -> viewVars [ '_serialize' ] , $ dataToSerialize ) ; } return $ this -> _serialize ( $ dataToSerialize ) ; }
Renders an AJAX view . The rendered content will be part of the JSON response object and can be accessed via response . content in JavaScript .
49,343
protected function _dataToSerialize ( $ serialize , $ additionalData = [ ] ) { if ( $ serialize === true ) { $ data = array_diff_key ( $ this -> viewVars , array_flip ( $ this -> _specialVars ) ) ; return $ data ; } foreach ( ( array ) $ serialize as $ alias => $ key ) { if ( is_numeric ( $ alias ) ) { $ alias = $ key ; } if ( array_key_exists ( $ key , $ this -> viewVars ) ) { $ additionalData [ $ alias ] = $ this -> viewVars [ $ key ] ; } } return $ additionalData ; }
Returns data to be serialized based on the value of viewVars .
49,344
private function getValues ( & $ data ) { $ values = [ ] ; foreach ( $ data as $ i => $ row ) { $ skipImport = isset ( $ this -> skipImport ) ? call_user_func ( $ this -> skipImport , $ row ) : false ; if ( ! $ skipImport ) { foreach ( $ this -> configs as $ config ) { $ value = call_user_func ( $ config [ 'value' ] , $ row ) ; $ values [ $ i ] [ $ config [ 'attribute' ] ] = $ value ; } } } $ values = $ this -> filterUniqueValues ( $ values ) ; return $ values ; }
Will get value list from the config
49,345
private function filterUniqueValues ( $ values ) { $ uniqueAttributes = [ ] ; foreach ( $ this -> configs as $ config ) { if ( isset ( $ config [ 'unique' ] ) && $ config [ 'unique' ] ) { $ uniqueAttributes [ ] = $ config [ 'attribute' ] ; } } if ( empty ( $ uniqueAttributes ) ) { return $ values ; } $ uniqueValues = [ ] ; foreach ( $ values as $ value ) { $ hash = "" ; foreach ( $ uniqueAttributes as $ ua ) { $ hash .= $ value [ $ ua ] ; } $ uniqueValues [ $ hash ] = $ value ; } return $ uniqueValues ; }
Will filter values per unique parameters . Config array can receive 1 + unique parameters .
49,346
public function authenticate ( $ username , $ token ) { if ( empty ( $ username ) || empty ( $ token ) ) { throw new \ ErrorException ( 'No username or token supplied.' ) ; } $ this -> username = $ username ; $ this -> token = $ token ; }
Set API credentials
49,347
private function makeRequest ( $ method , $ path , $ headers = array ( ) , $ params = '' ) { if ( time ( ) - $ this -> previousRequestTime < 1 ) { sleep ( 1 ) ; } $ response = call_user_func_array ( array ( $ this -> http , $ method ) , array ( $ path , $ headers , $ params ) ) ; $ this -> previousRequestTime = time ( ) ; list ( $ status , $ headers , $ body ) = $ response ; return $ this -> processResponse ( $ response ) ; }
Method for implementing request retry logic
49,348
private function processResponse ( $ response ) { list ( $ status , $ headers , $ body ) = $ response ; if ( $ status == 204 ) { return true ; } $ decoded = json_decode ( $ body , true ) ; if ( $ decoded === null ) { throw new RestException ( 'Could not decode response body as JSON.' , $ status ) ; } if ( 200 <= $ status && $ status < 300 ) { return $ decoded ; } throw new RestException ( $ decoded [ 'message' ] , $ decoded [ 'code' ] , ( isset ( $ decoded [ 'errors' ] ) ? $ decoded [ 'errors' ] : null ) ) ; }
Convert the JSON encoded response into a PHP object .
49,349
public function getErrors ( ) { $ result = array ( ) ; if ( count ( $ this -> errors ) > 0 ) { if ( isset ( $ this -> errors [ 'common' ] ) ) { $ result [ 'common' ] = $ this -> errors [ 'common' ] ; } if ( isset ( $ this -> errors [ 'fields' ] ) ) { foreach ( $ this -> errors [ 'fields' ] as $ key => $ value ) { $ result [ $ key ] = $ value ; } } } return $ result ; }
Get errors received from Textmagic API
49,350
private function isActiveRecordUnique ( $ attributes ) { $ class = $ this -> className ; return empty ( $ attributes ) ? true : ! $ class :: find ( ) -> where ( $ attributes ) -> exists ( ) ; }
Will check if Active Record is unique by exists query .
49,351
public function readFile ( ) { if ( ! file_exists ( $ this -> filename ) ) { throw new Exception ( __CLASS__ . ' couldn\'t find the CSV file.' ) ; } $ length = isset ( $ this -> fgetcsvOptions [ 'length' ] ) ? $ this -> fgetcsvOptions [ 'length' ] : 0 ; $ delimiter = isset ( $ this -> fgetcsvOptions [ 'delimiter' ] ) ? $ this -> fgetcsvOptions [ 'delimiter' ] : ',' ; $ enclosure = isset ( $ this -> fgetcsvOptions [ 'enclosure' ] ) ? $ this -> fgetcsvOptions [ 'enclosure' ] : '"' ; $ escape = isset ( $ this -> fgetcsvOptions [ 'escape' ] ) ? $ this -> fgetcsvOptions [ 'escape' ] : "\\" ; $ lines = [ ] ; if ( ( $ fp = fopen ( $ this -> filename , 'r' ) ) !== FALSE ) { while ( ( $ line = fgetcsv ( $ fp , $ length , $ delimiter , $ enclosure , $ escape ) ) !== FALSE ) { array_push ( $ lines , $ line ) ; } } for ( $ i = 0 ; $ i < $ this -> startFromLine ; $ i ++ ) { unset ( $ lines [ $ i ] ) ; } return $ lines ; }
Will read CSV file into array
49,352
public function getList ( $ params = array ( ) ) { $ this -> checkPermissions ( 'getList' ) ; return $ this -> client -> retrieveData ( $ this -> resourceName , $ params ) ; }
Retrive collection of model objects
49,353
public function create ( $ params = array ( ) ) { $ this -> checkPermissions ( 'create' ) ; return $ this -> client -> createData ( $ this -> resourceName , $ params ) ; }
Create new model object
49,354
public function get ( $ id ) { $ this -> checkPermissions ( 'get' ) ; return $ this -> client -> retrieveData ( $ this -> resourceName . '/' . $ id ) ; }
Retrieve model object
49,355
public function update ( $ id , $ params = array ( ) ) { $ this -> checkPermissions ( 'update' ) ; return $ this -> client -> updateData ( $ this -> resourceName . '/' . $ id , $ params ) ; }
Update model object
49,356
public function delete ( $ id ) { $ this -> checkPermissions ( 'delete' ) ; return $ this -> client -> deleteData ( $ this -> resourceName . '/' . $ id ) ; }
Delete model object
49,357
public function search ( $ params = array ( ) ) { $ this -> checkPermissions ( 'search' ) ; return $ this -> client -> retrieveData ( $ this -> resourceName . '/search' , $ params ) ; }
Search model object
49,358
public static function folderToZip ( $ folder , & $ zipFile , $ exclusiveLength , $ exclude = array ( '.git' ) , $ prefix = '' ) { if ( ! file_exists ( $ folder ) ) return ; $ handle = opendir ( $ folder ) ; while ( false !== $ f = readdir ( $ handle ) ) { if ( $ f != '.' && $ f != '..' ) { if ( in_array ( $ f , $ exclude ) ) continue ; $ filePath = "$folder/$f" ; $ localPath = $ prefix . substr ( $ filePath , $ exclusiveLength ) ; if ( is_file ( $ filePath ) ) { $ zipFile -> addFile ( $ filePath , $ localPath ) ; } elseif ( is_dir ( $ filePath ) ) { $ zipFile -> addEmptyDir ( $ localPath ) ; self :: folderToZip ( $ filePath , $ zipFile , $ exclusiveLength , $ exclude , $ prefix ) ; } } } closedir ( $ handle ) ; }
Add files and sub - directories in a folder to zip file .
49,359
public function multiLoad ( $ ids , $ doNotTestCacheValidity = false ) { if ( ! is_array ( $ ids ) ) { \ Zend_Cache :: throwException ( 'multiLoad() expects parameter 1 to be array, ' . gettype ( $ ids ) . ' given' ) ; } if ( $ doNotTestCacheValidity ) { $ this -> _log ( "\Zend_Cache_Backend_Memcached::load() : \$doNotTestCacheValidity=true is unsupported by the Memcached backend" ) ; } $ tmp = $ this -> _getHandle ( ) -> get ( $ ids ) ; foreach ( $ tmp as $ k => $ v ) { if ( is_array ( $ v ) ) { $ tmp [ $ k ] = $ v [ 0 ] ; } } return $ tmp ; }
Loads an array of items from the memcached . Extends \ Zend_Cache_Backend_Memcached with support of multi - get feature .
49,360
public function save ( $ data , $ id , $ tags = array ( ) , $ specificLifetime = false ) { $ result = parent :: save ( $ data , $ id , array ( ) , $ specificLifetime ) ; if ( $ tags ) { if ( ! method_exists ( $ this -> _handle , 'tag_add' ) ) { \ Zend_Cache :: throwException ( 'Method tag_add() is not supported by the PHP memcached extension!' ) ; } foreach ( $ tags as $ tag ) { $ this -> _handle -> tag_add ( $ tag , $ id ) ; } return true ; } return $ result ; }
Saves a data in memcached . Supports tags .
49,361
public function clean ( $ mode = \ Zend_Cache :: CLEANING_MODE_ALL , $ tags = array ( ) ) { if ( $ mode == \ Zend_Cache :: CLEANING_MODE_MATCHING_TAG ) { if ( $ tags ) { if ( ! method_exists ( $ this -> _handle , 'tag_delete' ) ) { \ Zend_Cache :: throwException ( 'Method tag_delete() is not supported by the PHP memcached extension!' ) ; } foreach ( $ tags as $ tag ) { $ this -> _handle -> tag_delete ( $ tag ) ; } } } else { return parent :: clean ( $ mode , $ tags ) ; } }
Cleaning operation with tag support .
49,362
public function save ( $ data ) { $ tags = array ( ) ; foreach ( $ this -> _tags as $ tag ) { $ tags [ ] = $ tag -> getNativeId ( ) ; } $ raw = serialize ( $ data ) ; $ this -> _getBackend ( ) -> save ( $ raw , $ this -> _id , $ tags , $ this -> _lifetime ) ; }
Saves a data for this slot .
49,363
public function addTag ( Dklab_Cache_Frontend_Tag $ tag ) { if ( $ tag -> getBackend ( ) !== $ this -> _getBackend ( ) ) { \ Zend_Cache :: throwException ( "Backends for tag " . get_class ( $ tag ) . " and slot " . get_class ( $ this ) . " must be same" ) ; } $ this -> _tags [ ] = $ tag ; }
Associates a tag with current slot .
49,364
public static function curlGet ( $ url ) { $ defaults = array ( CURLOPT_URL => $ url , CURLOPT_RETURNTRANSFER => TRUE , ) ; $ ch = curl_init ( ) ; curl_setopt_array ( $ ch , $ defaults ) ; if ( ! $ result = curl_exec ( $ ch ) ) { trigger_error ( curl_error ( $ ch ) ) ; } curl_close ( $ ch ) ; return $ result ; }
Send a GET requst using cURL
49,365
public function replace ( $ tableExpression , array $ data , array $ types = array ( ) ) { $ this -> connect ( ) ; if ( empty ( $ data ) ) { return $ this -> executeUpdate ( 'REPLACE INTO ' . $ tableExpression . ' ()' . ' VALUES ()' ) ; } return $ this -> executeUpdate ( 'REPLACE INTO ' . $ tableExpression . ' (' . implode ( ', ' , array_keys ( $ data ) ) . ')' . ' VALUES (' . implode ( ', ' , array_fill ( 0 , count ( $ data ) , '?' ) ) . ')' , array_values ( $ data ) , is_string ( key ( $ types ) ) ? $ this -> extractTypeValues ( $ data , $ types ) : $ types ) ; }
Inserts a table row with specified data . REPLACE works exactly like INSERT except that if an old row in the table has the same value as a new row for a PRIMARY KEY or a UNIQUE index the old row is deleted before the new row is inserted .
49,366
public function evaluate ( ) { $ node = $ this -> getNode ( ) ; if ( $ node instanceof NodeInterface ) { $ contentContext = $ node -> getContext ( ) ; if ( $ contentContext instanceof \ Neos \ Neos \ Domain \ Service \ ContentContext ) { $ site = $ contentContext -> getCurrentSite ( ) ; $ siteConfiguration = $ this -> siteConfigurationRepository -> findOneBySite ( $ site ) ; return $ siteConfiguration ; } } return null ; }
Find a SiteConfiguration entity for the current site
49,367
public function getNodeStat ( NodeInterface $ node , ControllerContext $ controllerContext , $ statIdentifier , \ DateTime $ startDate , \ DateTime $ endDate ) { $ this -> analytics -> requireAuthentication ( ) ; if ( ! isset ( $ this -> statsSettings [ $ statIdentifier ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Unknown stat identifier "%s"' , $ statIdentifier ) , 1416917316 ) ; } $ statConfiguration = $ this -> statsSettings [ $ statIdentifier ] ; $ siteConfiguration = $ this -> getSiteConfigurationByNode ( $ node ) ; $ startDateFormatted = $ startDate -> format ( 'Y-m-d' ) ; $ endDateFormatted = $ endDate -> format ( 'Y-m-d' ) ; $ nodeUri = $ this -> getLiveNodeUri ( $ node , $ controllerContext ) ; $ filters = 'ga:pagePath==' . $ nodeUri -> getPath ( ) . ';ga:hostname==' . $ nodeUri -> getHost ( ) ; $ parameters = [ 'filters' => $ filters ] ; if ( isset ( $ statConfiguration [ 'dimensions' ] ) ) { $ parameters [ 'dimensions' ] = $ statConfiguration [ 'dimensions' ] ; } if ( isset ( $ statConfiguration [ 'sort' ] ) ) { $ parameters [ 'sort' ] = $ statConfiguration [ 'sort' ] ; } if ( isset ( $ statConfiguration [ 'max-results' ] ) ) { $ parameters [ 'max-results' ] = $ statConfiguration [ 'max-results' ] ; } $ gaResult = $ this -> analytics -> data_ga -> get ( 'ga:' . $ siteConfiguration -> getProfileId ( ) , $ startDateFormatted , $ endDateFormatted , $ statConfiguration [ 'metrics' ] , $ parameters ) ; return new DataResult ( $ gaResult ) ; }
Get metrics and dimension values for a configured stat
49,368
public function indexAction ( ) { $ siteConfigurations = $ this -> siteConfigurationRepository -> findAll ( ) ; $ sites = $ this -> siteRepository -> findAll ( ) ; $ sitesWithConfiguration = [ ] ; foreach ( $ sites as $ site ) { $ item = [ 'site' => $ site ] ; foreach ( $ siteConfigurations as $ siteConfiguration ) { if ( $ siteConfiguration -> getSite ( ) === $ site ) { $ item [ 'configuration' ] = $ siteConfiguration ; } } $ sitesWithConfiguration [ ] = $ item ; } $ this -> view -> assign ( 'sitesWithConfiguration' , $ sitesWithConfiguration ) ; $ profiles = $ this -> getGroupedProfiles ( ) ; $ this -> view -> assign ( 'groupedProfiles' , $ profiles ) ; }
Show a list of sites and assigned GA profiles
49,369
public function updateAction ( array $ siteConfigurations ) { foreach ( $ siteConfigurations as $ siteConfiguration ) { if ( $ this -> persistenceManager -> isNewObject ( $ siteConfiguration ) ) { $ this -> siteConfigurationRepository -> add ( $ siteConfiguration ) ; } else { $ this -> siteConfigurationRepository -> update ( $ siteConfiguration ) ; } } $ this -> emitSiteConfigurationChanged ( ) ; $ this -> addFlashMessage ( 'Configuration has been updated.' , 'Update' , null , [ ] , 1417109043 ) ; $ this -> redirect ( 'index' ) ; }
Update or add site configurations
49,370
protected function callActionMethod ( ) { try { parent :: callActionMethod ( ) ; } catch ( \ Google_Service_Exception $ exception ) { $ this -> addFlashMessage ( '%1$s' , 'Google API error' , \ Neos \ Error \ Messages \ Message :: SEVERITY_ERROR , [ 'message' => $ exception -> getMessage ( ) , 1415797974 ] ) ; $ this -> forward ( 'errorMessage' ) ; } catch ( MissingConfigurationException $ exception ) { $ this -> addFlashMessage ( '%1$s' , 'Missing configuration' , \ Neos \ Error \ Messages \ Message :: SEVERITY_ERROR , [ 'message' => $ exception -> getMessage ( ) , 1415797974 ] ) ; $ this -> forward ( 'errorMessage' ) ; } catch ( AuthenticationRequiredException $ exception ) { $ this -> redirect ( 'authenticate' ) ; } }
Catch Google service exceptions and forward to the apiError action to show an error message .
49,371
protected function getGroupedProfiles ( ) { $ this -> analytics -> requireAuthentication ( ) ; $ groupedProfiles = [ ] ; $ accounts = $ this -> analytics -> management_accounts -> listManagementAccounts ( ) ; foreach ( $ accounts as $ account ) { $ groupedProfiles [ $ account -> getId ( ) ] [ 'label' ] = $ account -> getName ( ) ; $ groupedProfiles [ $ account -> getId ( ) ] [ 'items' ] = [ ] ; } $ webproperties = $ this -> analytics -> management_webproperties -> listManagementWebproperties ( '~all' ) ; $ webpropertiesById = [ ] ; foreach ( $ webproperties as $ webproperty ) { $ webpropertiesById [ $ webproperty -> getId ( ) ] = $ webproperty ; } $ profiles = $ this -> analytics -> management_profiles -> listManagementProfiles ( '~all' , '~all' ) ; foreach ( $ profiles as $ profile ) { if ( isset ( $ webpropertiesById [ $ profile -> getWebpropertyId ( ) ] ) ) { $ webproperty = $ webpropertiesById [ $ profile -> getWebpropertyId ( ) ] ; $ groupedProfiles [ $ profile -> getAccountId ( ) ] [ 'items' ] [ $ profile -> getId ( ) ] = [ 'label' => $ webproperty -> getName ( ) . ' > ' . $ profile -> getName ( ) , 'value' => $ profile -> getId ( ) ] ; } } return $ groupedProfiles ; }
Get profiles grouped by account and webproperty
49,372
protected function removeUriQueryArguments ( $ redirectUri ) { $ uri = new \ Neos \ Flow \ Http \ Uri ( $ redirectUri ) ; $ uri -> setQuery ( null ) ; $ redirectUri = ( string ) $ uri ; return $ redirectUri ; }
Remove query arguments from the given URI
49,373
public function bind ( $ address , $ port = 0 ) { return static :: exceptionOnFalse ( $ this -> resource , function ( $ resource ) use ( $ address , $ port ) { return @ socket_bind ( $ resource , $ address , $ port ) ; } ) ; }
Binds a name to a socket .
49,374
public function connect ( $ address , $ port = 0 ) { return static :: exceptionOnFalse ( $ this -> resource , function ( $ resource ) use ( $ address , $ port ) { return @ socket_connect ( $ resource , $ address , $ port ) ; } ) ; }
Connect to a socket .
49,375
public static function create ( $ domain , $ type , $ protocol ) { $ return = @ socket_create ( $ domain , $ type , $ protocol ) ; if ( $ return === false ) { throw new SocketException ( ) ; } $ socket = new self ( $ return ) ; $ socket -> domain = $ domain ; $ socket -> type = $ type ; $ socket -> protocol = $ protocol ; return $ socket ; }
Create a socket .
49,376
public static function createListen ( $ port , $ backlog = 128 ) { $ return = @ socket_create_listen ( $ port , $ backlog ) ; if ( $ return === false ) { throw new SocketException ( ) ; } $ socket = new self ( $ return ) ; $ socket -> domain = AF_INET ; return $ socket ; }
Opens a socket on port to accept connections .
49,377
public static function createPair ( $ domain , $ type , $ protocol ) { $ array = [ ] ; $ return = @ socket_create_pair ( $ domain , $ type , $ protocol , $ array ) ; if ( $ return === false ) { throw new SocketException ( ) ; } $ sockets = self :: constructFromResources ( $ array ) ; foreach ( $ sockets as $ socket ) { $ socket -> domain = $ domain ; $ socket -> type = $ type ; $ socket -> protocol = $ protocol ; } return $ sockets ; }
Creates a pair of indistinguishable sockets and stores them in an array .
49,378
public function getOption ( $ level , $ optname ) { return static :: exceptionOnFalse ( $ this -> resource , function ( $ resource ) use ( $ level , $ optname ) { return @ socket_get_option ( $ resource , $ level , $ optname ) ; } ) ; }
Gets socket options .
49,379
public function listen ( $ backlog = 0 ) { return static :: exceptionOnFalse ( $ this -> resource , function ( $ resource ) use ( $ backlog ) { return @ socket_listen ( $ resource , $ backlog ) ; } ) ; }
Listens for a connection on a socket .
49,380
public function read ( $ length , $ type = PHP_BINARY_READ ) { return static :: exceptionOnFalse ( $ this -> resource , function ( $ resource ) use ( $ length , $ type ) { return @ socket_read ( $ resource , $ length , $ type ) ; } ) ; }
reads a maximum of length bytes from a socket .
49,381
public function receive ( & $ buffer , $ length , $ flags ) { return static :: exceptionOnFalse ( $ this -> resource , function ( $ resource ) use ( & $ buffer , $ length , $ flags ) { return @ socket_recv ( $ resource , $ buffer , $ length , $ flags ) ; } ) ; }
Receives data from a connected socket .
49,382
protected static function exceptionOnFalse ( $ resource , callable $ closure ) { $ result = $ closure ( $ resource ) ; if ( $ result === false ) { throw new SocketException ( $ resource ) ; } return $ result ; }
Performs the closure function . If it returns false throws a SocketException using the provided resource .
49,383
public function write ( $ buffer , $ length = null ) { if ( null === $ length ) { $ length = strlen ( $ buffer ) ; } do { $ return = @ socket_write ( $ this -> resource , $ buffer , $ length ) ; if ( false !== $ return && $ return < $ length ) { $ buffer = substr ( $ buffer , $ return ) ; $ length -= $ return ; } else { break ; } } while ( true ) ; if ( $ return === false ) { throw new SocketException ( $ this -> resource ) ; } return $ return ; }
Write to a socket .
49,384
public function send ( $ buffer , $ flags = 0 , $ length = null ) { if ( null === $ length ) { $ length = strlen ( $ buffer ) ; } do { $ return = @ socket_send ( $ this -> resource , $ buffer , $ length , $ flags ) ; if ( false !== $ return && $ return < $ length ) { $ buffer = substr ( $ buffer , $ return ) ; $ length -= $ return ; } else { break ; } } while ( true ) ; if ( $ return === false ) { throw new SocketException ( $ this -> resource ) ; } return $ return ; }
Sends data to a connected socket .
49,385
protected function loopOnce ( ) { $ read = array_merge ( [ $ this -> masterSocket ] , $ this -> clients ) ; $ write = null ; $ except = null ; $ ret = Socket :: select ( $ read , $ write , $ except , $ this -> timeout ) ; if ( ! is_null ( $ this -> timeout ) && $ ret == 0 ) { if ( $ this -> triggerHooks ( self :: HOOK_TIMEOUT , $ this -> masterSocket ) === false ) { return false ; } } if ( in_array ( $ this -> masterSocket , $ read ) ) { unset ( $ read [ array_search ( $ this -> masterSocket , $ read ) ] ) ; $ socket = $ this -> masterSocket -> accept ( ) ; $ this -> clients [ ] = $ socket ; if ( $ this -> triggerHooks ( self :: HOOK_CONNECT , $ socket ) === false ) { return false ; } unset ( $ socket ) ; } foreach ( $ read as $ client ) { $ input = $ this -> read ( $ client ) ; if ( $ input === '' ) { if ( $ this -> disconnect ( $ client ) === false ) { return false ; } } else { if ( $ this -> triggerHooks ( self :: HOOK_INPUT , $ client , $ input ) === false ) { return false ; } } unset ( $ input ) ; } unset ( $ read ) ; unset ( $ write ) ; unset ( $ except ) ; return true ; }
This is the main server loop . This code is responsible for adding connections and triggering hooks .
49,386
public function disconnect ( Socket $ client , $ message = '' ) { $ clientIndex = array_search ( $ client , $ this -> clients ) ; $ return = $ this -> triggerHooks ( self :: HOOK_DISCONNECT , $ this -> clients [ $ clientIndex ] , $ message ) ; $ this -> clients [ $ clientIndex ] -> close ( ) ; unset ( $ this -> clients [ $ clientIndex ] ) ; unset ( $ client ) ; if ( $ return === false ) { return false ; } unset ( $ return ) ; return true ; }
Disconnect the supplied Client Socket .
49,387
protected function triggerHooks ( $ command , Socket $ client , $ input = null ) { if ( isset ( $ this -> hooks [ $ command ] ) ) { foreach ( $ this -> hooks [ $ command ] as $ callable ) { $ continue = call_user_func ( $ callable , $ this , $ client , $ input ) ; if ( $ continue === self :: RETURN_HALT_HOOK ) { break ; } if ( $ continue === self :: RETURN_HALT_SERVER ) { return false ; } unset ( $ continue ) ; } } return true ; }
Triggers the hooks for the supplied command .
49,388
public function addHook ( $ command , $ callable ) { if ( ! isset ( $ this -> hooks [ $ command ] ) ) { $ this -> hooks [ $ command ] = [ ] ; } else { $ k = array_search ( $ callable , $ this -> hooks [ $ command ] ) ; if ( $ k !== false ) { return ; } unset ( $ k ) ; } $ this -> hooks [ $ command ] [ ] = $ callable ; }
Attach a Listener to a Hook .
49,389
public function removeHook ( $ command , $ callable ) { if ( isset ( $ this -> hooks [ $ command ] ) && array_search ( $ callable , $ this -> hooks [ $ command ] ) !== false ) { $ hook = array_search ( $ callable , $ this -> hooks [ $ command ] ) ; unset ( $ this -> hooks [ $ command ] [ $ hook ] ) ; unset ( $ hook ) ; } }
Remove the provided Callable from the provided Hook .
49,390
private function shutDownEverything ( ) { foreach ( $ this -> clients as $ client ) { $ this -> disconnect ( $ client ) ; } $ this -> masterSocket -> close ( ) ; unset ( $ this -> hooks , $ this -> address , $ this -> port , $ this -> timeout , $ this -> domain , $ this -> masterSocket , $ this -> maxClients , $ this -> maxRead , $ this -> clients , $ this -> readType ) ; }
Disconnect all the Clients and shut down the server .
49,391
public function getData ( NodeInterface $ node = null , array $ arguments ) { if ( ! isset ( $ arguments [ 'stat' ] ) ) { throw new \ InvalidArgumentException ( 'Missing "stat" argument' , 1416864525 ) ; } $ startDateArgument = isset ( $ arguments [ 'startDate' ] ) ? $ arguments [ 'startDate' ] : '3 months ago' ; $ endDateArgument = isset ( $ arguments [ 'endDate' ] ) ? $ arguments [ 'endDate' ] : '1 day ago' ; try { $ startDate = new \ DateTime ( $ startDateArgument ) ; } catch ( \ Exception $ exception ) { return [ 'error' => [ 'message' => 'Invalid date format for argument "startDate"' , 'code' => 1417435564 ] ] ; } try { $ endDate = new \ DateTime ( $ endDateArgument ) ; } catch ( \ Exception $ exception ) { return [ 'error' => [ 'message' => 'Invalid date format for argument "endDate"' , 'code' => 1417435581 ] ] ; } try { $ stats = $ this -> reporting -> getNodeStat ( $ node , $ this -> controllerContext , $ arguments [ 'stat' ] , $ startDate , $ endDate ) ; $ data = [ 'data' => $ stats ] ; return $ data ; } catch ( \ Google_Service_Exception $ exception ) { $ errors = $ exception -> getErrors ( ) ; return [ 'error' => [ 'message' => isset ( $ errors [ 0 ] [ 'message' ] ) ? $ errors [ 0 ] [ 'message' ] : 'Google API returned error' , 'code' => isset ( $ errors [ 0 ] [ 'reason' ] ) ? $ errors [ 0 ] [ 'reason' ] : 1417606128 ] ] ; } catch ( Exception $ exception ) { return [ 'error' => [ 'message' => $ exception -> getMessage ( ) , 'code' => $ exception -> getCode ( ) ] ] ; } }
Get analytics stats for the given node
49,392
public function upload ( UploadedFile $ uploadedFile , $ newFilename = null , $ path = null ) { $ this -> prepareTargetUploadPath ( $ path ) ; $ this -> getUploadedOriginalFileProperties ( $ uploadedFile ) ; $ this -> setNewFilename ( $ newFilename ) ; $ this -> saveOriginalFile ( $ uploadedFile ) ; $ this -> createThumbnails ( $ uploadedFile ) ; return $ this -> returnOutput ( ) ; }
The main method upload the file .
49,393
private function prepareConfigs ( ) { $ this -> library = Config :: get ( 'imageupload.library' , 'gd' ) ; $ this -> quality = Config :: get ( 'imageupload.quality' , 90 ) ; $ this -> uploadpath = Config :: get ( 'imageupload.path' , public_path ( 'uploads/images' ) ) ; $ this -> newfilename = Config :: get ( 'imageupload.newfilename' , 'original' ) ; $ this -> dimensions = Config :: get ( 'imageupload.dimensions' ) ; $ this -> suffix = Config :: get ( 'imageupload.suffix' , true ) ; $ this -> exif = Config :: get ( 'imageupload.exif' , false ) ; $ this -> output = Config :: get ( 'imageupload.output' , 'array' ) ; $ this -> intervention -> configure ( [ 'driver' => $ this -> library ] ) ; return $ this ; }
Get and prepare configs .
49,394
private function createDirectoryIfNotExists ( $ absoluteTargetPath ) { if ( File :: isDirectory ( $ absoluteTargetPath ) && File :: isWritable ( $ absoluteTargetPath ) ) { return true ; } try { @ File :: makeDirectory ( $ absoluteTargetPath , 0777 , true ) ; return true ; } catch ( Exception $ e ) { throw new ImageuploadException ( $ e -> getMessage ( ) ) ; } }
Check and create directory if not exists .
49,395
private function prepareTargetUploadPath ( $ path = null ) { $ absoluteTargetPath = implode ( '/' , array_filter ( [ rtrim ( $ this -> uploadpath , '/' ) , trim ( dirname ( $ path ) , '/' ) , ] ) ) ; $ this -> results [ 'path' ] = $ absoluteTargetPath ; $ this -> results [ 'dir' ] = $ this -> getRelativePath ( $ absoluteTargetPath ) ; return $ this -> createDirectoryIfNotExists ( $ absoluteTargetPath ) ; }
Set target upload path .
49,396
private function getThumbnailsTargetUploadFilepath ( $ key ) { $ absoluteThumbnailTargetPath = implode ( '/' , array_filter ( [ rtrim ( $ this -> results [ 'path' ] , '/' ) , ( ! $ this -> suffix ? trim ( $ key ) : '' ) , ] ) ) ; $ this -> createDirectoryIfNotExists ( $ absoluteThumbnailTargetPath ) ; $ resizedBasename = implode ( '_' , [ $ this -> results [ 'basename' ] , $ key , ] ) ; if ( ! $ this -> suffix ) { $ resizedBasename = $ this -> results [ 'basename' ] ; } $ resizedBasename .= '.' . $ this -> results [ 'original_extension' ] ; return implode ( '/' , [ $ absoluteThumbnailTargetPath , $ resizedBasename ] ) ; }
Set thumbnail target upload file path .
49,397
private function setNewFilename ( $ newfilename = null ) { $ extension = $ this -> results [ 'original_extension' ] ; $ originalFilename = $ this -> results [ 'original_filename' ] ; $ timestamp = Carbon :: now ( ) -> getTimestamp ( ) ; switch ( $ this -> newfilename ) { case 'hash' : $ newfilename = md5 ( $ originalFilename . $ timestamp ) ; break ; case 'random' : $ newfilename = Str :: random ( 16 ) ; break ; case 'timestamp' : $ newfilename = $ timestamp ; break ; case 'custom' : $ newfilename = ( ! empty ( $ newfilename ) ? $ newfilename : $ originalFilename ) ; break ; default : $ newfilename = pathinfo ( $ originalFilename , PATHINFO_FILENAME ) ; } $ this -> results [ 'basename' ] = ( string ) $ newfilename ; $ this -> results [ 'filename' ] = $ newfilename . '.' . $ extension ; return $ this ; }
Set new file name from config .
49,398
private function saveOriginalFile ( UploadedFile $ uploadedFile ) { try { $ targetFilepath = implode ( '/' , [ $ this -> results [ 'path' ] , $ this -> results [ 'filename' ] , ] ) ; $ image = $ this -> intervention -> make ( $ uploadedFile ) ; if ( $ this -> exif && ! empty ( $ image -> exif ( ) ) ) { $ this -> results [ 'exif' ] = $ image -> exif ( ) ; } $ image -> save ( $ targetFilepath , $ this -> quality ) ; $ s3_url = $ this -> saveToS3 ( $ image , $ targetFilepath ) ; $ this -> results [ 'original_width' ] = ( int ) $ image -> width ( ) ; $ this -> results [ 'original_height' ] = ( int ) $ image -> height ( ) ; $ this -> results [ 'original_filepath' ] = $ targetFilepath ; $ this -> results [ 'original_filedir' ] = $ this -> getRelativePath ( $ targetFilepath ) ; $ this -> results [ 's3_url' ] = $ s3_url ; } catch ( Exception $ e ) { throw new ImageuploadException ( $ e -> getMessage ( ) ) ; } return $ this ; }
Upload and save original file .
49,399
private function getUploadedOriginalFileProperties ( UploadedFile $ uploadedFile ) { $ this -> results [ 'original_filename' ] = $ uploadedFile -> getClientOriginalName ( ) ; $ this -> results [ 'original_filepath' ] = $ this -> getRelativePath ( $ uploadedFile -> getRealPath ( ) ) ; $ this -> results [ 'original_filedir' ] = $ uploadedFile -> getRealPath ( ) ; $ this -> results [ 'original_extension' ] = $ uploadedFile -> getClientOriginalExtension ( ) ; $ this -> results [ 'original_filesize' ] = ( int ) $ uploadedFile -> getSize ( ) ; $ this -> results [ 'original_mime' ] = $ uploadedFile -> getMimeType ( ) ; return $ this ; }
Prepare original file properties .