idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
37,900
public function compare ( AnDate $ date ) { $ thisTimestamp = $ this -> getTimestamp ( ) ; $ dateTimestamp = $ date -> getTimestamp ( ) ; return $ thisTimestamp - $ dateTimestamp ; }
Compare the reciever with another date . If receiver is the same date as the date it returns 0 if receiver is before the dat it returns 1 and if it s after the date it returns - 1 .
37,901
public function modify ( $ change ) { $ date = clone $ this ; $ date -> setDate ( strtotime ( $ change , $ this -> getDate ( DATE_FORMAT_UNIXTIME ) ) ) ; return $ date ; }
Returns a modified date object .
37,902
protected function _actionBrowse ( $ context ) { $ this -> getService ( 'repos:photos.set' ) ; $ photos = parent :: _actionBrowse ( $ context ) ; $ photos -> order ( 'creationTime' , 'DESC' ) ; if ( $ this -> exclude_set != '' ) { $ set = $ this -> actor -> sets -> fetch ( array ( 'id' => $ this -> exclude_set ) ) ; if...
Browse Photos .
37,903
protected function _actionAdd ( $ context ) { $ data = $ context -> data ; $ file = AnRequest :: get ( 'files.file' , 'raw' ) ; $ content = @ file_get_contents ( $ file [ 'tmp_name' ] ) ; $ filesize = strlen ( $ content ) ; $ uploadlimit = $ this -> _max_upload_limit * 1024 * 1024 ; $ exif = ( function_exists ( 'exif_r...
Method to upload and Add a photo .
37,904
public function setDatabaseInfo ( $ data ) { $ data [ 'host' ] = $ data [ 'host' ] . ':' . $ data [ 'port' ] ; unset ( $ data [ 'port' ] ) ; $ keys = array_map ( function ( $ key ) { return 'database_' . $ key ; } , array_keys ( $ data ) ) ; $ data = array_combine ( $ keys , array_values ( $ data ) ) ; $ this -> set ( ...
Set configuration database info
37,905
public function getDatabaseInfo ( ) { $ parts = explode ( ':' , $ this -> database_host ) ; $ info = array ( 'host' => $ parts [ 0 ] , 'port' => isset ( $ parts [ 1 ] ) ? $ parts [ 1 ] : '3306' , 'user' => $ this -> database_user , 'password' => $ this -> database_password , 'name' => $ this -> database_name , 'prefix'...
Get the database info
37,906
public function append ( array $ alias , $ mode = LibBaseTemplateFilter :: MODE_READ ) { if ( $ mode & LibBaseTemplateFilter :: MODE_READ ) { $ this -> _alias_read = array_merge ( $ this -> _alias_read , $ alias ) ; } if ( $ mode & LibBaseTemplateFilter :: MODE_WRITE ) { $ this -> _alias_write = array_merge ( $ this ->...
Append an alias
37,907
public function setData ( array $ data ) { foreach ( $ data as $ key => $ value ) { if ( isset ( $ this -> _data [ $ key ] ) ) { $ filter = $ this -> _data [ $ key ] -> filter ; if ( $ value !== null ) { if ( $ value !== '' ) { if ( ! ( $ filter instanceof AnFilterInterface ) ) { $ filter = AnService :: get ( 'anahita:...
Set the state data
37,908
public function getData ( $ unique = false ) { $ data = array ( ) ; foreach ( $ this -> _data as $ name => $ state ) { if ( isset ( $ state -> value ) ) { if ( $ unique ) { if ( $ state -> unique && $ this -> _validate ( $ state ) ) { $ result = true ; foreach ( $ state -> required as $ required ) { if ( ! $ this -> _v...
Get the state data
37,909
public function toArray ( $ values = true ) { if ( $ values ) { $ result = array ( ) ; foreach ( $ this -> _data as $ state ) { $ result [ $ state -> name ] = $ state -> value ; } } else { $ result = $ this -> _data ; } return $ result ; }
Return an associative array of the states .
37,910
public static function getInstance ( $ name , $ config = array ( ) ) { static $ instance ; if ( ! $ instance ) { $ instance = new static ( ) ; } $ object = clone $ instance ; $ config [ 'name' ] = $ name ; $ object -> append ( $ config ) -> append ( array ( 'attribs' => array ( 'id' => null , ) , ) ) ; return $ object ...
Instantiate a template object .
37,911
public static function parseSize ( $ size ) { $ height = null ; $ width = null ; if ( count ( ( array ) $ size ) == 2 || strpos ( $ size , 'x' ) ) { list ( $ width , $ height ) = is_array ( $ size ) ? $ size : explode ( 'x' , $ size ) ; } else { $ size = ( array ) $ size ; $ width = ( int ) $ size [ 0 ] ; } return arra...
Parses a string based size convention to width and height .
37,912
public static function resize ( $ image , $ size ) { if ( ! $ image ) { return false ; } list ( $ width , $ height ) = self :: parseSize ( $ size ) ; if ( $ height == 'auto' && $ width == 'auto' ) { return false ; } $ o_wd = imagesx ( $ image ) ; $ o_ht = imagesy ( $ image ) ; $ x = $ y = 0 ; if ( $ height == 'auto' ) ...
Resizes an image using the passed size and return the resized image resource .
37,913
public static function output ( $ image , $ type ) { $ parts = explode ( '/' , $ type ) ; $ func = 'image' . strtolower ( $ parts [ 1 ] ) ; if ( ! function_exists ( $ func ) ) { return ; } $ args = null ; switch ( $ parts [ 1 ] ) { case 'jpeg' : $ args = array ( $ image , null , 100 ) ; break ; case 'png' : $ args = ar...
Outputs an image to the desired image type .
37,914
public function getValue ( $ key , $ default = null ) { $ meta = $ this -> meta ; if ( isset ( $ meta [ $ key ] ) ) { return $ meta [ $ key ] ; } return $ default ; }
Returns the dictionary value of a given key . If there are no values then return the default value .
37,915
public function addMention ( $ username ) { if ( $ mentioned = $ this -> getService ( 'repos:people.person' ) -> find ( array ( 'username' => $ username ) ) ) { $ this -> mentions -> insert ( $ mentioned ) ; if ( $ this -> _mixer -> isSubscribable ( ) && ! $ this -> _mixer -> subscribed ( $ mentioned ) ) { $ this -> _m...
Adds a person to a mentionable mixer entity .
37,916
public function removeMention ( $ username ) { if ( $ mentioned = $ this -> getService ( 'repos:people.person' ) -> find ( array ( 'username' => $ username ) ) ) { $ this -> mentions -> extract ( $ mentioned ) ; if ( $ this -> _mixer -> isSubscribable ( ) && $ this -> _mixer -> subscribed ( $ mentioned ) ) { $ this -> ...
Removes a person from a mentionable mixer entity .
37,917
protected function _actionGet ( AnCommandContext $ context ) { $ this -> setView ( 'searches' ) ; if ( $ this -> actor ) { $ this -> getToolbar ( 'actorbar' ) -> setTitle ( $ this -> actor -> name ) ; $ this -> getService ( ) -> set ( 'com:search.owner' , $ this -> actor ) ; } $ this -> _state -> insert ( 'term' ) -> i...
Search and return the result .
37,918
protected function _actionBrowse ( $ context ) { $ sets = parent :: _actionBrowse ( $ context ) ; $ sets -> order ( 'updateTime' , 'DESC' ) ; if ( $ this -> photo_id && $ this -> getRequest ( ) -> get ( 'layout' ) != 'selector' ) { $ sets -> where ( 'photos.id' , '=' , $ this -> photo_id ) ; } return $ sets ; }
Browse Albums .
37,919
protected function _actionUpdatephotos ( $ context ) { $ this -> execute ( 'addphoto' , $ context ) ; $ photo_ids = ( array ) AnConfig :: unbox ( $ context -> data -> photo_id ) ; foreach ( $ this -> getItem ( ) -> photos as $ photo ) { if ( ! in_array ( $ photo -> id , $ photo_ids ) ) { $ this -> getItem ( ) -> remove...
Updates the photos in a set given an array of ids .
37,920
protected function _actionReorder ( $ context ) { $ photo_ids = ( array ) AnConfig :: unbox ( $ context -> data -> photo_id ) ; $ this -> getItem ( ) -> reorder ( $ photo_ids ) ; return $ this -> getItem ( ) ; }
Reorders the photos in a set in respect with the order of ids .
37,921
protected function _actionAddphoto ( $ context ) { $ this -> getItem ( ) -> addPhoto ( $ this -> photo ) ; $ context -> response -> setRedirect ( route ( $ this -> getItem ( ) -> getURL ( ) ) ) ; return $ this -> getItem ( ) ; }
Adds a photos to an set .
37,922
protected function _actionRemovephoto ( $ context ) { $ lastPhoto = ( $ this -> getItem ( ) -> photos -> getTotal ( ) > 1 ) ? false : true ; $ this -> getItem ( ) -> removePhoto ( $ this -> photo ) ; if ( $ lastPhoto ) { $ this -> getResponse ( ) -> status = 204 ; return ; } else { return $ this -> getItem ( ) ; } }
Removes a list of photos from an set .
37,923
public function fetchPhoto ( AnCommandContext $ context ) { $ data = $ context -> data ; $ data -> append ( array ( 'photo_id' => $ this -> photo_id , ) ) ; $ photo_id = ( array ) AnConfig :: unbox ( $ data -> photo_id ) ; if ( ! empty ( $ photo_id ) ) { $ photo = $ this -> actor -> photos -> fetchSet ( array ( 'id' =>...
Fetches a photo object given photo_id as a GET request .
37,924
public function createStory ( $ config = array ( ) ) { $ config = new AnConfig ( $ config ) ; $ config -> append ( array ( 'subject' => get_viewer ( ) , 'owner' => get_viewer ( ) , 'component' => 'com_' . $ this -> _mixer -> getIdentifier ( ) -> package , ) ) ; $ story = $ this -> getService ( 'repos:stories.story' ) -...
Creates a story .
37,925
public function getCommonLeaders ( $ actor ) { if ( ! isset ( $ this -> __common_leaders ) ) { $ ids = array_intersect ( $ this -> leaderIds -> toArray ( ) , $ actor -> leaderIds -> toArray ( ) ) ; $ ids [ ] = - 1 ; $ query = $ this -> getService ( 'repos:actors.actor' ) -> getQuery ( ) -> where ( 'id' , 'IN' , $ ids )...
Return this person common leader with another person .
37,926
public function getMutuals ( ) { if ( ! isset ( $ this -> __mutuals ) ) { $ ids = array_intersect ( $ this -> leaderIds -> toArray ( ) , $ this -> followerIds -> toArray ( ) ) ; $ query = $ this -> getService ( 'repos:people.person' ) -> getQuery ( ) -> where ( 'id' , 'IN' , $ ids ) ; $ this -> __mutuals = $ query -> t...
Return the mutual followers .
37,927
protected function _actionAdd ( $ context ) { $ entity = parent :: _actionAdd ( $ context ) ; if ( $ entity -> owner -> isSubscribable ( ) ) { $ notification = $ this -> createNotification ( array ( 'name' => 'topic_add' , 'object' => $ entity , 'subscribers' => $ entity -> owner -> subscriberIds -> toArray ( ) , ) ) -...
When a topic is added then create a notification .
37,928
public function getURL ( ) { if ( ! isset ( $ this -> _url ) ) { $ this -> _url = 'option=' . $ this -> component . '&view=' . $ this -> _mixer -> getIdentifier ( ) -> name ; if ( $ this -> _mixer -> id ) { $ this -> _url .= '&id=' . $ this -> _mixer -> id ; } } return $ this -> _url ; }
Returns the resource URL .
37,929
public function createStoryCallback ( AnCommandContext $ context ) { if ( $ context -> result !== false ) { $ data = $ context -> data ; $ name = $ this -> getIdentifier ( ) -> name . '_' . $ context -> action ; $ context -> append ( array ( 'story' => array ( 'component' => 'com_' . $ this -> getIdentifier ( ) -> pack...
Can be used as a cabllack to automatically create a story .
37,930
protected function _addAddress ( $ email , $ name , $ type ) { $ type = '_' . $ type ; $ allowed = array ( '_sender' , '_from' , '_to' , '_cc' , '_bcc' , '_reply_to' ) ; if ( in_array ( $ type , $ allowed ) ) { if ( $ name != '' ) { $ this -> { $ type } [ $ email ] = $ name ; } else { $ this -> { $ type } [ ] = $ email...
Adds an address
37,931
protected function _getTransport ( ) { if ( $ this -> _mailer === 'smtp' ) { $ transport = Swift_SmtpTransport :: newInstance ( $ this -> _site_settings -> smtphost , $ this -> _site_settings -> smtpport ) -> setUsername ( $ this -> _site_settings -> smtpuser ) -> setPassword ( $ this -> _site_settings -> smtppass ) ; ...
Obtains the swift mailer transport object
37,932
protected function _createMessage ( ) { $ message = Swift_Message :: newInstance ( ) -> setCharset ( $ this -> _charset ) -> setContentType ( $ this -> _contentType ) -> setPriority ( $ this -> _priority ) -> setMaxLineLength ( $ this -> _maxLineLength ) -> setSubject ( $ this -> _subject ) -> setTo ( $ this -> _to ) -...
Creates a message to be sent out
37,933
public static function setDefaultClass ( $ identifier , $ classname ) { self :: $ _defaults [ ( string ) $ identifier ] = $ classname ; unset ( self :: $ _identifiers [ ( string ) $ identifier ] ) ; }
Sets a default class .
37,934
public static function registerDefault ( $ config ) { if ( ! isset ( $ config [ 'identifier' ] ) ) { throw new AnException ( 'identifier [AnServiceIdentifier] options is requied' ) ; } $ strIdentifier = ( string ) $ config [ 'identifier' ] ; if ( isset ( $ config [ 'default' ] ) ) { $ config [ 'default' ] = ( array ) $...
Registers a default .
37,935
public static function findDefaultClass ( $ identifier ) { $ strIdentifier = ( string ) $ identifier ; if ( isset ( self :: $ _defaults [ $ strIdentifier ] ) ) { $ classname = self :: $ _defaults [ $ strIdentifier ] ; if ( $ classname === false || class_exists ( $ classname ) ) { return $ classname ; } } $ classbase = ...
Finds the default class for an identifier or return null .
37,936
protected function _getRepositoryForTable ( $ table ) { if ( ! isset ( $ this -> _table_repositories [ $ table ] ) ) { $ identifier = clone $ this -> _mixer -> getIdentifier ( ) ; $ identifier -> type = 'repos' ; $ identifier -> name = uniqid ( ) ; $ repository = $ this -> getService ( $ identifier , array ( 'resources...
Return a repository for a table . This method is used to create a repository on the fly for the para tables .
37,937
public function addBehavior ( $ behavior , $ config = array ( ) ) { if ( ! ( $ behavior instanceof AnBehaviorInterface ) ) { $ behavior = $ this -> _mixer -> getBehavior ( $ behavior , $ config ) ; } $ this -> _behaviors [ $ behavior -> getIdentifier ( ) -> name ] = $ behavior ; $ this -> getCommandChain ( ) -> enqueue...
Add one or more behaviors to the controller
37,938
public function getBehavior ( $ behavior , $ config = array ( ) ) { $ identifier = $ behavior ; if ( ! ( $ behavior instanceof AnServiceIdentifier ) ) { if ( is_string ( $ behavior ) && strpos ( $ behavior , '.' ) === false ) { $ identifier = clone $ this -> getIdentifier ( ) ; $ identifier -> path = array ( $ identifi...
Get a behavior by identifier
37,939
public static function getInstance ( $ property , AnConfig $ config ) { $ description = $ config [ 'description' ] ; $ name = $ config [ 'name' ] ; if ( ! $ name || ! $ description ) { throw new AnDomainPropertyException ( 'name [string] or desription [AnDomainDescriptionAbstract] options are missing' ) ; } if ( $ desc...
Creates and initialize a property . The instantiation happens through cloning rather then creating a new instance .
37,940
public function setConfig ( AnConfig $ config ) { if ( isset ( $ this -> __config ) ) { $ this -> __config -> append ( $ config ) ; foreach ( $ this -> __config as $ key => $ value ) { $ config [ $ key ] = $ this -> __config [ $ key ] ; } } else { $ this -> __config = $ config ; } $ this -> _name = $ config -> name ; $...
Configures a property . Property are cloned so using this method it s possibled to re - configured a cloned property .
37,941
public function getURL ( ) { $ url = $ this -> _internal_request -> get_normalized_http_url ( ) ; if ( $ this -> getMethod ( ) == AnHttpRequest :: GET ) { $ url = $ this -> _internal_request -> to_url ( ) ; } return $ url ; }
Return the request URL .
37,942
public function send ( ) { $ url = $ this -> getURL ( ) ; $ data = $ this -> getData ( ) ; $ method = $ this -> getMethod ( ) ; $ ch = curl_init ( ) ; $ options = $ this -> _options ; curl_setopt_array ( $ ch , array ( CURLOPT_USERAGENT => $ options -> useragent , CURLOPT_CONNECTTIMEOUT => $ options -> connection_timeo...
Sends a request and returns the response .
37,943
public function setCurrentVersion ( $ version ) { $ version = min ( $ this -> getMaxVersion ( ) , $ version ) ; $ version = max ( $ version , 0 ) ; $ this -> _getVersion ( ) -> version = $ version ; $ this -> _getVersion ( ) -> saveEntity ( ) ; }
Set the current version .
37,944
public function getVersions ( ) { if ( ! isset ( $ this -> _versions ) ) { $ versions = array ( ) ; foreach ( $ this -> getMethods ( ) as $ method ) { $ matches = array ( ) ; if ( preg_match ( '/(up)(\d+)/' , $ method , $ matches ) ) { $ versions [ ] = $ matches [ 2 ] ; } } $ path = dirname ( $ this -> getIdentifier ( ...
Return the max version .
37,945
public function getVersionsBehind ( ) { $ current = $ this -> getCurrentVersion ( ) ; $ versions = array_filter ( $ this -> getVersions ( ) , function ( $ version ) use ( $ current ) { return $ version > $ current ; } ) ; return count ( $ versions ) ; }
Retunr the number of versions behind .
37,946
public function generateMigration ( $ version = null ) { $ path = dirname ( $ this -> getIdentifier ( ) -> filepath ) . '/migrations' ; $ next = $ this -> getMaxVersion ( ) + 1 ; $ migration_file = "$path/$next.php" ; if ( ! file_exists ( $ migration_file ) ) { if ( ! file_exists ( dirname ( $ migration_file ) ) ) { mk...
Generates a migration . If no version is set then version is created based on max version .
37,947
protected function _getVersion ( ) { if ( ! isset ( $ this -> _version ) ) { $ this -> _db -> execute ( <<<EOFCREATE TABLE IF NOT EXISTS `#__migrator_versions` ( `id` int(11) NOT NULL AUTO_INCREMENT, `component` varchar(255) NOT NULL, `version` text NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `component` (`component`...
Return the version .
37,948
public function getTables ( ) { if ( $ this -> _tables == self :: AUTO_DETECT_TABLES ) { $ tables = $ this -> _db -> show ( 'SHOW TABLES' , AnDatabase :: FETCH_FIELD_LIST ) ; $ prefix = $ this -> _db -> getTablePrefix ( ) . $ this -> getIdentifier ( ) -> package . '_' ; $ schemas = array ( ) ; foreach ( $ tables as $ t...
Return an array of table names .
37,949
public function inspect ( $ dump = true ) { $ data = array ( ) ; foreach ( $ this as $ entity ) { $ data [ ] = $ entity -> inspect ( false ) ; } if ( $ dump ) { var_dump ( $ data ) ; } else { return $ data ; } }
Inspects the entityset .
37,950
public function getRepository ( ) { if ( ! $ this -> _repository instanceof AnDomainRepositoryAbstract ) { if ( ! $ this -> _repository instanceof AnServiceIdentifier ) { $ this -> setRepository ( $ this -> _repository ) ; } $ this -> _repository = $ this -> getService ( $ this -> _repository ) ; } return $ this -> _re...
Return the entityset repository .
37,951
public function count ( $ load = true ) { if ( isset ( $ this -> _query ) && ! $ this -> isLoaded ( ) && ! $ load ) { $ query = AnDomainQuery :: getInstance ( $ this -> getRepository ( ) , $ this -> _query ) ; return $ query -> fetchValue ( 'count(*)' ) ; } else { $ this -> _loadData ( ) ; $ result = parent :: count ( ...
Count Data .
37,952
final protected function _loadData ( ) { if ( ! $ this -> isLoaded ( ) ) { $ this -> _object_set = new ArrayObject ( ) ; foreach ( $ this -> _getData ( ) as $ object ) { $ this -> insert ( $ object ) ; } } }
If the data is null then load the data .
37,953
public function instantiate ( $ identifier , $ config = array ( ) ) { $ filters = ( array ) $ identifier ; $ filter = array_shift ( $ filters ) ; $ filter = $ this -> _createFilter ( $ filter , $ config ) ; foreach ( $ filters as $ name ) { $ filter -> addFilter ( self :: _createFilter ( $ name , $ config ) ) ; } retur...
Factory method for AnFilterInterface classes .
37,954
protected function _createFilter ( $ filter , $ config ) { try { if ( is_string ( $ filter ) && strpos ( $ filter , '.' ) === false ) { $ filter = 'com:default.filter.' . trim ( $ filter ) ; } $ filter = $ this -> getService ( $ filter , $ config ) ; } catch ( AnServiceServiceException $ e ) { throw new AnFilterExcepti...
Create a filter based on it s name
37,955
public function validateEntity ( $ person ) { $ this -> _validateField ( $ person , 'email' ) ; $ this -> _validateField ( $ person , 'username' ) ; $ this -> _validateField ( $ person , 'password' ) ; return parent :: validateEntity ( $ person ) ; }
Validates a person object .
37,956
protected function _actionVote ( $ context ) { $ context -> response -> status = AnHttpResponse :: CREATED ; $ this -> getItem ( ) -> voteup ( get_viewer ( ) ) ; $ notification = $ this -> _mixer -> createNotification ( array ( 'name' => 'voteup' , 'object' => $ this -> getItem ( ) , 'component' => $ this -> getItem ( ...
Subscribe the viewer to the subscribable object .
37,957
protected function _actionUnvote ( $ context ) { $ this -> getItem ( ) -> unvote ( get_viewer ( ) ) ; $ context -> response -> content = $ this -> _mixer -> execute ( 'getvoters' , $ context ) ; }
Remove the viewer s subscription from the subscribable object .
37,958
public function display ( ) { $ name = $ this -> getName ( ) ; $ this -> _data = array_merge ( $ this -> _state -> toArray ( ) , $ this -> _data ) ; if ( $ items = $ this -> _state -> getList ( ) ) { $ this -> _data [ AnInflector :: pluralize ( $ name ) ] = $ items ; $ this -> _data [ 'items' ] = $ items ; } if ( $ ite...
Sets the .
37,959
public function assignedToActor ( $ actor ) { $ actortype = $ actor -> getEntityDescription ( ) -> getInheritanceColumnValue ( ) -> getIdentifier ( ) ; $ this -> where ( 'assignments.actor' , '=' , $ actor ) -> where ( '(@col(assignments.actortype) = @quote(' . $ actortype . ') AND @col(assignments.access IN (2,1) ))' ...
Adds a condition for list of components that are assigned to actor .
37,960
public function addRequester ( $ requester ) { $ leader = $ this -> _mixer ; if ( $ leader -> eql ( $ requester ) ) { return false ; } if ( $ requester -> following ( $ leader ) ) { return false ; } if ( $ leader -> blocking ( $ requester ) ) { return false ; } $ edge = $ this -> getService ( 'repos:actors.request' ) -...
Add a follow requester to the actor .
37,961
public function removeRequester ( $ requester ) { $ leader = $ this -> _mixer ; $ data = array ( 'requester' => $ requester , 'requestee' => $ leader , ) ; $ this -> getService ( 'repos:actors.request' ) -> destroy ( $ data ) ; $ this -> resetStats ( array ( $ leader , $ requester ) ) ; }
Removes an actor from the list of blocked .
37,962
public function addFollower ( $ follower ) { $ leader = $ this -> _mixer ; if ( $ leader -> eql ( $ follower ) ) { return false ; } if ( $ leader -> blocking ( $ follower ) ) { return false ; } if ( $ follower -> requested ( $ leader ) ) { $ leader -> removeRequester ( $ follower ) ; } $ edge = $ this -> getService ( '...
Add a follower to the actor .
37,963
public function removeFollower ( $ follower ) { $ leader = $ this -> _mixer ; if ( $ leader -> isSubscribable ( ) ) { $ leader -> removeSubscriber ( $ follower ) ; } $ this -> removeNodeSubscriptions ( $ leader , $ follower ) ; if ( $ leader -> isAdministrable ( ) ) { $ leader -> removeAdministrator ( $ follower ) ; } ...
Remove an actor to from list of the followers . If the leader is subscribable then it will remove the follower from the list of it s subscribers .
37,964
public function addLeader ( $ leader ) { $ follower = $ this -> _mixer ; if ( $ follower -> eql ( $ leader ) ) { return false ; } if ( $ leader -> blocking ( $ follower ) ) { return false ; } if ( $ follower -> requested ( $ leader ) ) { $ leader -> removeRequester ( $ follower ) ; } $ edge = $ this -> getService ( 're...
Add a leader to the actor .
37,965
protected function _beforeRepositoryFetch ( AnCommandContext $ context ) { if ( AnService :: has ( 'viewer' ) ) { $ query = $ context -> query ; $ repository = $ query -> getRepository ( ) ; $ viewer = get_viewer ( ) ; if ( $ viewer -> id ) { $ query -> where ( "IF( FIND_IN_SET({$viewer->id}, @col(blockedIds)), 0, 1)" ...
Adds a filter to the query based on the access mode .
37,966
public function removeNodeSubscriptions ( $ leader , $ follower ) { $ query = $ this -> getService ( 'repos:base.subscription' ) -> getQuery ( ) -> subscriber ( $ follower ) -> where ( 'subscribee.id' , 'IN' , $ this -> getService ( 'repos:base.node' ) -> getQuery ( ) -> columns ( 'id' ) -> where ( 'owner_id' , '=' , $...
Remove all the subscriptions of a follower to the nodes owned by a leader .
37,967
public function load ( $ template ) { $ path [ 'manifest' ] = $ this -> _buildManifestPath ( $ template ) ; if ( file_exists ( $ path [ 'manifest' ] ) ) { $ this -> alias = $ template ; $ this -> thumbnail = AnRequest :: root ( ) . '/templates/' . $ template . '/thumbnail.png' ; $ manifest = json_decode ( file_get_cont...
Load the entity properties from template json file
37,968
public function save ( ) { $ path = $ this -> _buildParamsPath ( $ this -> alias ) ; if ( file_exists ( $ path ) ) { chmod ( $ path , 0644 ) ; } $ params = '' ; foreach ( $ this -> params as $ key => $ value ) { $ params .= $ key . '=' . $ value . "\n" ; } try { file_put_contents ( $ path , $ params ) ; } catch ( Excep...
Forwards the call to the space commit entities .
37,969
public function canLogin ( ) { $ subscriber_id = AnRequest :: get ( 'session.subscriber_id' , 'cmd' ) ; if ( $ subscriber_id ) { $ this -> person = $ this -> getService ( 'repos:people.person' ) -> find ( $ subscriber_id ) ; } return ! is_null ( $ this -> person ) ; }
Can login .
37,970
public function addLocation ( $ locations ) { $ newItems = AnHelperArray :: getIterator ( $ locations ) ; foreach ( $ newItems as $ item ) { if ( ! $ this -> locations -> find ( $ item ) ) { $ this -> locations -> insert ( $ item ) ; } } return $ item ; }
add locations to a locatable node
37,971
protected function _filterDistance ( AnCommandContext $ context ) { $ query = $ context -> query ; $ location = $ query -> search_nearby ; $ lat = $ location [ 'latitude' ] ; $ lng = $ location [ 'longitude' ] ; $ range = $ query -> search_range * 1000 ; $ calc_distance = 'CEIL((ACOS(SIN(' . $ lat . '*PI()/180) * SIN(@...
Filter the nodes nearby a particular longitude and latitude
37,972
protected function _actionGetaccesstoken ( $ context ) { $ this -> getAPI ( ) -> requestAccessToken ( $ this -> getRequest ( ) ) ; $ token = ( array ) $ this -> getAPI ( ) -> getToken ( ) ; $ consumer = ( array ) $ this -> _consumer ; AnRequest :: set ( 'session.oauth' , array ( 'api' => $ this -> getAPI ( ) -> getName...
Handles callback .
37,973
protected function _actionOauthorize ( $ context ) { $ data = $ context -> data ; AnRequest :: set ( 'session.return' , ( string ) $ data -> return ) ; AnRequest :: set ( 'session.oauth' , null ) ; $ view = $ this -> _mixer -> getIdentifier ( ) -> name ; $ this -> getAPI ( ) -> setToken ( null ) ; $ context -> response...
Authorize an oauth profile to an actor . It needs to authorize .
37,974
protected function _beforeControllerGet ( AnCommandContext $ context ) { if ( $ this -> _mixer -> getRequest ( ) -> get == 'accesstoken' ) { $ this -> _mixer -> execute ( 'getaccesstoken' , $ context ) ; return false ; } else { $ this -> api = $ this -> getAPI ( ) ; } }
Set the api to the data in the context .
37,975
public function getAPI ( ) { if ( ! isset ( $ this -> _api ) ) { $ session = AnRequest :: get ( 'session.oauth' , 'raw' , array ( ) ) ; $ session = new AnConfig ( $ session ) ; $ api = pick ( $ this -> getRequest ( ) -> server , $ session -> api ) ; if ( ! $ api ) { return ; } $ this -> _api = $ this -> getService ( 'c...
Get the oatuh adapter using the controller name .
37,976
public function canOauthorize ( ) { $ api = $ this -> getAPI ( ) ; if ( $ api && $ this -> actor ) { return $ api -> canAddService ( $ this -> actor ) ; } return ! is_null ( $ api ) ; }
Check if oauthorize is allowed .
37,977
public function removeCoverImage ( ) { $ sizes = $ this -> _mixer -> getValue ( 'sizes' ) ; if ( empty ( $ sizes ) ) { $ sizes = explode ( ' ' , 'original large medium' ) ; } else { $ sizes = array_keys ( $ sizes ) ; } foreach ( $ sizes as $ size ) { $ file = $ this -> _mixer -> getCoverFile ( $ size ) ; $ this -> _mix...
Removes the cover image .
37,978
public function getCoverFile ( $ size ) { $ coverFilename = $ this -> coverFilename ; $ extension = explode ( '.' , $ coverFilename ) ; $ extension = array_pop ( $ extension ) ; $ name = preg_replace ( '#\.[^.]*$#' , '' , $ coverFilename ) ; $ coverFilename = $ name . '_' . $ size . '.' . $ extension ; return $ coverFi...
Return the cover file for a size . Override the Coverable behavior due to some legacy .
37,979
public function getCoverURL ( $ size = 'large' ) { $ coverFilename = $ this -> _mixer -> getCoverFile ( $ size ) ; $ url = $ this -> getPathURL ( $ coverFilename , true ) ; return $ url ; }
Return the URL to the cover .
37,980
public function getCoverSizes ( ) { $ sizes = $ this -> getValue ( 'sizes' ) ; if ( empty ( $ sizes ) ) { $ sizes = $ this -> _sizes ; } return $ sizes ; }
Obtain the list of available sizes and dimensions for this cover .
37,981
public function setCover ( $ config ) { $ config = new AnConfig ( $ config ) ; $ config -> append ( array ( 'mimetype' => 'image/jpeg' , ) ) ; if ( $ config -> url ) { $ config -> append ( array ( 'data' => file_get_contents ( $ config -> url ) , ) ) ; } $ config -> mimetype = strtolower ( $ config -> mimetype ) ; $ mi...
Set the cover .
37,982
protected function _afterEntityUpdate ( AnCommandContext $ context ) { if ( isset ( $ this -> _pending_files [ $ this -> _mixer ] ) ) { $ files = $ this -> _pending_files [ $ this -> _mixer ] ; foreach ( $ files as $ filename => $ data ) { $ this -> _mixer -> writeData ( $ filename , $ data ) ; } unset ( $ this -> _pen...
Called after the entity is updated .
37,983
public function logo ( $ config = array ( ) ) { $ config = new AnConfig ( $ config ) ; $ config -> append ( array ( 'show_logo' => pick ( $ this -> _params -> showLogo , 1 ) , 'name' => pick ( $ this -> _params -> brandName , 'Anahita' ) , 'url' => 'base://' , ) ) ; $ showLogo = ( $ config -> show_logo ) ? ' brand-logo...
Renders the logo hyperlinked .
37,984
public function favicon ( $ config = array ( ) ) { $ config = new AnConfig ( $ config ) ; $ config -> append ( array ( 'favicon' => pick ( $ this -> _params -> favicon , 'favicon.ico' ) , 'type' => 'image/png' , 'style' => pick ( $ this -> _params -> cssStyle , 'style1' ) , 'url' => 'base://' , ) ) ; $ paths = array ( ...
Renders the favicon tag .
37,985
public function style ( $ config = array ( ) ) { require_once 'less/compiler.php' ; $ config = new AnConfig ( $ config ) ; $ config -> append ( array ( 'parse_urls' => true , 'style' => pick ( $ this -> _params -> cssStyle , 'style1' ) , 'compile' => pick ( $ this -> _params -> compilestyle , 0 ) , 'compress' => pick (...
Renders the template style .
37,986
public function messages ( ) { $ session = AnService :: get ( 'com:sessions' ) ; $ queue = ( array ) $ session -> get ( 'controller.queue' , array ( ) ) ; $ session -> set ( 'controller.queue' , null ) ; if ( isset ( $ queue [ 'message' ] ) ) { $ message = $ queue [ 'message' ] ; $ config = array ( 'closable' => true )...
Render the document queued messages .
37,987
public function stream_open ( $ path ) { $ identifier = str_replace ( 'tmpl://' , '' , $ path ) ; $ template = AnService :: get ( $ identifier ) -> top ( ) ; $ this -> _path = $ template -> getPath ( ) ; $ this -> _data = $ template -> parse ( ) ; $ this -> _stat = array ( 'mode' => 0100777 , 'size' => strlen ( $ this ...
Opens the template file and converts markup .
37,988
public function write ( & $ text ) { $ matches = array ( ) ; if ( preg_match_all ( '/<a(.*?)>/' , $ text , $ matches ) ) { foreach ( $ matches [ 1 ] as $ index => $ match ) { $ attribs = $ this -> _parseAttributes ( $ match ) ; $ attribs [ 'style' ] = 'color:#076da0;text-decoration:none' ; $ attribs = AnHelperArray :: ...
Fixes blockquotes .
37,989
public function addEntry ( $ entry ) { $ date = new AnDate ( ) ; if ( ! isset ( $ entry [ 'date' ] ) ) { $ entry [ 'date' ] = $ date -> format ( "%Y-%m-%d" ) ; } if ( ! isset ( $ entry [ 'time' ] ) ) { $ entry [ 'time' ] = $ date -> format ( "%H:%M:%S" ) ; } if ( ! isset ( $ entry [ 'c-ip' ] ) ) { $ entry [ 'c-ip' ] = ...
Adds a log entry
37,990
protected function _openLog ( ) { if ( is_resource ( $ this -> _file ) ) { return true ; } $ now = new AnDate ( ) ; $ date = $ now -> getDate ( ) ; if ( ! file_exists ( $ this -> _path ) ) { $ header [ ] = "#<? die('Direct Access To Log Files Not Permitted'); ?>" ; $ header [ ] = "#Version: 1.0" ; $ header [ ] = "#Date...
Open the log file pointer and create the file if it doesn t exist
37,991
public function getSubscriptions ( ) { if ( ! $ this -> __subscriptions ) { $ subscriptions = array ( ) ; $ reflection = new ReflectionClass ( $ this ) ; foreach ( $ reflection -> getMethods ( ReflectionMethod :: IS_PUBLIC ) as $ method ) { if ( substr ( $ method -> name , 0 , 2 ) === 'on' ) { $ subscriptions [ ] = $ m...
Get a list of subscribed events
37,992
protected function _commandEdit ( $ command ) { $ entity = $ this -> getController ( ) -> getItem ( ) ; $ view = $ this -> getController ( ) -> getView ( ) -> getName ( ) ; $ layout = pick ( $ command -> layout , 'edit' ) ; $ command -> append ( array ( 'label' => AnTranslator :: _ ( 'LIB-AN-ACTION-EDIT' ) ) ) -> href ...
Edit Command for an entity .
37,993
protected function _actionBrowse ( $ context ) { if ( ! $ context -> query ) { $ context -> query = $ this -> getRepository ( ) -> getQuery ( ) ; } $ query = $ context -> query ; $ query -> order ( 'open' , 'DESC' ) ; if ( $ this -> sort == 'priority' ) { $ query -> order ( 'priority' , 'DESC' ) ; } return parent :: _a...
Browse Todos .
37,994
public function fetchActor ( ) { if ( $ entity = $ this -> getItem ( ) ) { $ id = $ entity -> actorId ; $ actor = $ this -> getService ( 'repos:people.person' ) -> find ( array ( 'id' => $ id ) ) ; $ this -> actor = $ actor ; } }
Sets controller s actor if a single entity is loaded .
37,995
public function picker ( $ name , $ options = array ( ) ) { $ options = new AnConfig ( $ options ) ; $ options -> append ( array ( 'date' => new AnDate ( ) , ) ) ; $ date = $ options -> date ; $ html = $ this -> getService ( 'com:base.template.helper.html' ) ; if ( is_string ( $ date ) ) { $ date = new AnDate ( new AnC...
Date picker . Return a selcetor with all the date components .
37,996
public function humanize ( $ date , $ config = array ( ) ) { $ config = new AnConfig ( $ config ) ; $ config -> append ( array ( 'format' => '%B %d %Y' , 'relative' => false , 'offset' => null , ) ) ; $ format = $ config -> format ; $ diff = $ this -> _current_time -> getDate ( DATE_FORMAT_UNIXTIME ) - $ date -> getDat...
Return a human friendly format of the date .
37,997
protected function _afterEntityDelete ( AnCommandContext $ context ) { if ( ! empty ( $ this -> __sets ) ) { foreach ( $ this -> __sets as $ set ) { if ( $ set -> photos -> getTotal ( ) == 0 ) { $ set -> delete ( ) ; } } } }
Delete the photo from all the sets .
37,998
public function onAfterControllerGetgraph ( AnEvent $ event ) { $ actor = $ this -> getController ( ) -> actor ; $ type = $ this -> getController ( ) -> type ; if ( $ actor -> authorize ( 'lead' ) && $ type == 'followers' ) { $ this -> addCommand ( 'AddFollowers' , array ( 'actor' => $ actor ) ) ; } }
Called after controller Getgraph .
37,999
public function addToolbarCommands ( ) { $ actor = $ this -> getController ( ) -> getItem ( ) ; $ viewer = get_viewer ( ) ; $ this -> _use_post = true ; $ this -> addListCommands ( ) ; if ( $ actor -> authorize ( 'administration' ) ) { $ this -> addCommand ( 'edit-actor' , array ( 'label' => AnTranslator :: _ ( 'LIB-AN...
Called before toolbar commands .