idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
37,600
public static function getMonthFullname ( $ month ) { $ month = ( int ) $ month ; $ names = self :: getMonthNames ( ) ; return $ names [ $ month ] ; }
Returns the full month name for the given month
37,601
public static function getMonthAbbrname ( $ month , $ length = 3 ) { $ month = ( int ) $ month ; return substr ( self :: getMonthFullname ( $ month ) , 0 , $ length ) ; }
Returns the abbreviated month name for the given month
37,602
public static function getMonthNames ( ) { static $ months ; if ( ! isset ( $ months ) ) { $ months = array ( ) ; for ( $ i = 1 ; $ i < 13 ; $ i ++ ) { $ months [ $ i ] = strftime ( '%B' , mktime ( 0 , 0 , 0 , $ i , 1 , 2001 ) ) ; } } return $ months ; }
Returns an array of month names
37,603
public static function getWeekDays ( ) { static $ weekdays = null ; if ( $ weekdays == null ) { $ weekdays = array ( ) ; for ( $ i = 0 ; $ i < 7 ; $ i ++ ) { $ weekdays [ $ i ] = strftime ( '%A' , mktime ( 0 , 0 , 0 , 1 , $ i , 2001 ) ) ; } } return $ weekdays ; }
Returns an array of week days
37,604
public static function getDaysInMonth ( $ month , $ year ) { if ( $ year == 1582 && $ month == 10 ) { return 21 ; } if ( $ month == 2 ) { if ( self :: isLeapYear ( $ year ) ) { return 29 ; } else { return 28 ; } } elseif ( $ month == 4 or $ month == 6 or $ month == 9 or $ month == 11 ) { return 30 ; } else { return 31 ...
Find the number of days in the given month
37,605
public static function isLeapYear ( $ year ) { if ( preg_match ( '/\D/' , $ year ) ) { return false ; } if ( $ year < 1000 ) { return false ; } if ( $ year < 1582 ) { return ( $ year % 4 == 0 ) ; } else { return ( ( $ year % 4 == 0 ) && ( $ year % 100 != 0 ) ) || ( $ year % 400 == 0 ) ; } }
Returns true for a leap year else false
37,606
protected function _renderStyle ( $ style , $ link , $ attribs = array ( ) ) { if ( $ link ) { $ style = pick ( $ this -> getService ( 'com:base.template.asset' ) -> getURL ( $ style ) , $ style ) ; } if ( AnRequest :: type ( ) == 'AJAX' ) { if ( $ link ) { $ file = $ this -> getService ( 'com:base.template.asset' ) ->...
Render style information .
37,607
public function fetchLocatable ( AnCommandContext $ context ) { $ this -> locatable = AnService :: get ( 'repos:nodes.node' ) -> getQuery ( ) -> disableChain ( ) -> id ( $ this -> locatable_id ) -> fetch ( ) ; if ( ! $ this -> locatable ) { throw new LibBaseControllerExceptionNotFound ( 'Locatable object does not exist...
Method to fetch the locatable object
37,608
public function writeData ( $ path = '' , $ data , $ public = true ) { $ path = $ this -> getStoragePath ( $ path ) ; return $ this -> _storage -> write ( $ path , $ data , $ public ) ; }
Write data to entity storage .
37,609
public function readData ( $ path = '' , $ public = true ) { $ path = $ this -> getStoragePath ( $ path ) ; return $ this -> _storage -> read ( $ path , $ public ) ; }
Read data from entity storage .
37,610
public function deletePath ( $ path = '' , $ public = true ) { $ path = $ this -> getStoragePath ( $ path ) ; return $ this -> _storage -> delete ( $ path , $ public ) ; }
Delete an existing data with the path .
37,611
public function pathExists ( $ path = '' , $ public = true ) { $ path = $ this -> getStoragePath ( $ path ) ; return $ this -> _storage -> exists ( $ path , $ public ) ; }
Checks the existance of path .
37,612
protected function _afterEntityInsert ( AnCommandContext $ context ) { if ( $ this -> isOwnable ( ) && $ this -> owner -> isNotifiable ( ) && ! $ this -> owner -> eql ( $ this -> author ) ) { $ this -> addSubscriber ( $ this -> owner ) ; } elseif ( ! empty ( $ this -> author ) ) { $ this -> addSubscriber ( $ this -> au...
Subscribe the author to the node .
37,613
public function subscribed ( $ subscriber ) { if ( $ subscriber -> id && $ this -> subscriberIds -> offsetExists ( $ subscriber -> id ) ) { return true ; } return false ; }
Return whether the person s is subsribed or not .
37,614
public function addSubscriber ( $ person ) { if ( $ this -> eql ( $ person ) ) { return false ; } if ( $ this -> subscribed ( $ person ) ) { return false ; } $ subscription = $ this -> subscriptions -> findOrAddNew ( array ( 'subscriber' => $ person , ) ) -> setData ( array ( 'component' => $ this -> component , 'autho...
Adds a person as the subscriber .
37,615
public function removeSubscriber ( $ person ) { $ mixer = $ this -> _mixer ; $ subscription = $ this -> subscriptions -> find ( array ( 'subscriber' => $ person , 'subscribee' => $ mixer , ) ) ; if ( $ subscription ) { $ this -> subscriptions -> extract ( $ subscription ) ; return $ this -> _mixer ; } }
Removes a person from the list of subscriber of the node .
37,616
public function resetStats ( array $ entities ) { foreach ( $ entities as $ entity ) { $ ids = $ entity -> subscriptions -> getQuery ( ) -> disableChain ( ) -> fetchValues ( 'subscriber.id' ) ; $ entity -> set ( 'subscriberCount' , count ( $ ids ) ) ; $ entity -> set ( 'subscriberIds' , AnDomainAttribute :: getInstance...
Reset subscriptions stats .
37,617
public function shareObject ( $ config = array ( ) ) { $ config = new AnConfig ( $ config ) ; if ( ! $ config -> object ) { throw new InvalidArgumentException ( 'Not object specified to share' ) ; } $ config -> append ( array ( 'sharer' => get_viewer ( ) , ) ) ; if ( $ config -> object -> isOwnable ( ) ) { $ config -> ...
Share an object using share adapters .
37,618
public function addAdministrationCommands ( ) { $ entity = $ this -> getController ( ) -> getItem ( ) ; if ( $ entity -> isOwnable ( ) && $ entity -> owner -> authorize ( 'administration' ) ) { if ( $ entity -> isEnablable ( ) ) { $ this -> addCommand ( 'enable' ) ; } if ( $ entity -> isCommentable ( ) ) { $ this -> ad...
Add Admin Commands for an entity .
37,619
protected function _commandPin ( $ command ) { $ entity = $ this -> getController ( ) -> getItem ( ) ; $ label = ( $ entity -> pinned ) ? AnTranslator :: _ ( 'LIB-AN-ACTION-UNPIN' ) : AnTranslator :: _ ( 'LIB-AN-ACTION-PIN' ) ; $ command -> append ( array ( 'label' => $ label ) ) -> href ( $ entity -> getURL ( ) . '&ac...
Customize the sticky command .
37,620
public function authorizeEcho ( AnCommandContext $ context ) { $ actor = $ context -> actor ; if ( $ actor -> isAdministrable ( ) && $ actor -> authorize ( 'administration' ) ) { return true ; } else { return $ actor -> id == $ context -> viewer -> id ; } }
Authorizes echo .
37,621
public function addPath ( $ path ) { settype ( $ path , 'array' ) ; foreach ( $ path as $ dir ) { $ dir = trim ( $ dir ) ; if ( substr ( $ dir , - 1 ) == DIRECTORY_SEPARATOR ) { $ dir = substr_replace ( $ dir , '' , - 1 ) ; } array_unshift ( $ this -> _paths , $ dir ) ; } }
Add relative search base paths from ANPATH_BASE in which look for the media . The paths are added to the beginging of the search list .
37,622
public function getURL ( $ url , & $ filepath = null ) { $ paths = $ this -> _paths ; if ( array_key_exists ( $ url , $ this -> _urls ) ) { return $ this -> _urls [ $ url ] ; } settype ( $ paths , 'array' ) ; $ this -> _urls [ $ url ] = null ; $ base = $ this -> getService ( 'application' ) -> getRouter ( ) -> getBaseU...
Searches through a list of paths to find a media file . To obtain the media full physical path .
37,623
protected function _afterControllerGet ( ) { if ( $ this -> _mixer -> isIdentifiable ( ) && $ this -> isDispatched ( ) ) { $ item = $ this -> _mixer -> getItem ( ) ; $ scope = $ this -> _mixer -> getIdentifier ( ) -> package . '.' . $ this -> _mixer -> getIdentifier ( ) -> name ; $ scope = $ this -> getService ( 'com:c...
Sets the search owner context and scope automatically .
37,624
protected function _afterEntityInsert ( AnCommandContext $ context ) { $ this -> set -> setValue ( 'photo_count' , $ this -> set -> photos -> reset ( ) -> getTotal ( ) ) ; }
After adding a relationship set the photo count for the set ; .
37,625
protected function _afterEntityDelete ( AnCommandContext $ context ) { $ total = $ this -> set -> photos -> reset ( ) -> getTotal ( ) ; if ( $ total > 0 ) { $ this -> set -> setValue ( 'photo_count' , $ this -> set -> photos -> reset ( ) -> getTotal ( ) ) ; } else { $ this -> set -> delete ( ) ; } }
After deleting a relationship set the photo count for the set ; .
37,626
private function __key ( $ key ) { if ( $ key instanceof AnObjectHandlable ) { $ key = $ key -> getHandle ( ) ; } elseif ( gettype ( $ key ) == 'object' ) { $ key = spl_object_hash ( $ key ) ; } return $ key ; }
Return a key .
37,627
public function validateCode ( $ code ) { $ coupon = $ this -> _controller -> getRepository ( ) -> find ( array ( 'code' => $ code ) ) ; if ( $ coupon && ! $ coupon -> expired ( ) ) { $ discount = $ coupon -> discount * 100 ; $ this -> setMessage ( AnTranslator :: sprintf ( 'COM-SUBSCRIPTIONS-VALID-COUPON' , $ discount...
Validates a coupon code .
37,628
public function shouldNotify ( $ person , $ notification , $ setting ) { $ should_notify = self :: NOTIFY_WITH_EMAIL ; if ( $ setting && ! $ setting -> sendEmail ( 'posts' , true ) ) { $ should_notify = self :: NOTIFY ; } return $ should_notify ; }
Checks with whether to notify a person or not .
37,629
public function set ( $ name , $ value = null , $ namespace = '' ) { if ( $ this -> _state !== self :: STATE_ACTIVE ) { throw new LibSessionsException ( "Session isn't active!\n" ) ; } $ namespace = empty ( $ namespace ) ? $ this -> _namespace : $ namespace ; if ( is_null ( $ value ) ) { unset ( $ _SESSION [ $ namespac...
Set data into the session store
37,630
public function has ( $ name ) { if ( $ this -> _state !== self :: STATE_ACTIVE ) { throw new LibSessionsException ( "Session isn't active!\n" ) ; } return isset ( $ _SESSION [ $ this -> _namespace ] [ $ name ] ) ; }
Check wheter data exists in the session store
37,631
public function restart ( ) { $ this -> destroy ( ) ; if ( $ this -> _state !== self :: STATE_DESTROYED ) { throw new LibSessionsException ( "Session is not destroyed!\n" ) ; } $ this -> _storage -> register ( ) ; $ this -> _state = self :: STATE_RESTART ; $ id = $ this -> _createToken ( strlen ( $ this -> getId ( ) ) ...
restart an expired or locked session
37,632
protected function _beforeEntityUpdate ( AnCommandContext $ context ) { if ( $ this -> getModifiedData ( ) -> ordering ) { $ store = $ this -> getRepository ( ) -> getStore ( ) ; $ query = $ this -> getScopedQuery ( $ context -> entity ) ; $ change = $ this -> getModifiedData ( ) -> ordering ; if ( $ change -> new - $ ...
Before Update .
37,633
public function reorder ( ) { $ store = $ this -> getRepository ( ) -> getStore ( ) ; $ query = $ this -> getScopedQuery ( $ this -> _mixer ) ; $ store -> execute ( 'SET @order = 0' ) ; $ query -> update ( '@col(ordering) = (@order := @order + 1)' ) -> order ( 'ordering' , 'ASC' ) ; $ store -> execute ( $ query ) ; }
Reorders all the entities .
37,634
public function getScopedQuery ( $ entity ) { $ query = $ this -> getRepository ( ) -> getQuery ( ) ; foreach ( $ this -> _scopes as $ key => $ value ) { if ( is_numeric ( $ key ) ) { $ key = $ value ; $ value = $ entity -> $ key ; } $ query -> where ( $ key , '=' , $ value ) ; } return $ query ; }
Return the query after applying the scope .
37,635
public function reset ( ) { $ this -> _set_query = null ; $ this -> _loaded = false ; $ this -> _object_set = new ArrayObject ( ) ; return $ this ; }
Revert the query back to the original .
37,636
public function getTotal ( ) { $ query = clone $ this -> getQuery ( ) ; $ query -> order = null ; $ query -> limit = null ; return $ query -> fetchValue ( 'COUNT(*)' ) ; }
Return the total number of entities that match the entityset query .
37,637
protected function _getData ( ) { $ data = $ this -> getRepository ( ) -> fetch ( $ this -> getQuery ( ) , AnDomain :: FETCH_ENTITY_LIST ) ; return $ data ; }
Loads the data into the object set using the query if not already loaded .
37,638
public function insert ( $ name , $ default = null , $ unique = false , $ required = array ( ) ) { $ state = new stdClass ( ) ; $ state -> name = $ name ; $ state -> value = pick ( $ this -> $ name , $ default ) ; $ state -> unique = $ unique ; $ state -> required = $ required ; $ state -> default = $ default ; $ this ...
Insert a new state . This state can uniquely identify a resources or set of resoruces .
37,639
public function isUnique ( ) { $ unique = false ; $ states = $ this -> getData ( true ) ; if ( ! empty ( $ states ) ) { $ unique = true ; foreach ( $ states as $ state ) { if ( is_array ( $ state ) && count ( $ state ) > 1 ) { $ unique = false ; break ; } } } return $ unique ; }
Check if the state information is unique .
37,640
protected function _validate ( $ state ) { if ( empty ( $ state -> value ) && ! is_numeric ( $ state -> value ) ) { return false ; } if ( is_array ( $ state -> value ) ) { $ first = array_slice ( $ state -> value , 0 , 1 ) ; if ( empty ( $ first ) && ! is_numeric ( $ first ) ) { return false ; } } return true ; }
Validate a unique state .
37,641
public function updateLegacyPluginsParams ( ) { $ db = AnService :: get ( 'anahita:domain.store.database' ) ; $ pluginColumns = $ db -> getColumns ( 'plugins' ) ; if ( isset ( $ pluginColumns [ 'params' ] ) ) { $ db -> execute ( 'ALTER TABLE `#__plugins` CHANGE `params` `meta` text DEFAULT NULL' ) ; $ db -> execute ( '...
if the plugins table still has a legacy params field rename it to meta to be consistent with Anahita s convention
37,642
public function getComponent ( ) { if ( ! ( $ this -> _controller instanceof LibBaseControllerAbstract ) ) { $ this -> _controller = $ this -> getController ( ) ; if ( ! $ this -> _controller instanceof LibBaseControllerAbstract ) { throw new \ UnexpectedValueException ( 'Dispatcher: ' . get_class ( $ this -> _controll...
Method to get a dispatcher object .
37,643
public function setComponent ( $ component , $ config = array ( ) ) { if ( ! ( $ component instanceof LibBaseControllerAbstract ) ) { if ( is_string ( $ component ) && strpos ( $ component , '.' ) === false ) { $ identifier = clone $ this -> getIdentifier ( ) ; $ identifier -> package = $ component ; } else { $ identif...
Method to set a dispatcher object .
37,644
protected function _actionRoute ( AnCommandContext $ context ) { $ url = clone AnRequest :: url ( ) ; $ url = $ this -> _application -> getRouter ( ) -> parse ( $ url ) ; AnRequest :: set ( 'get' , $ url -> query ) ; $ url -> query = AnRequest :: get ( 'get' , 'raw' ) ; $ this -> getRequest ( ) -> append ( $ url -> que...
Parses the route .
37,645
protected function _actionLoad ( $ context ) { if ( $ this -> _application instanceof ComApplication ) { return ; } set_exception_handler ( array ( $ this , 'exception' ) ) ; $ identifier = clone $ this -> getIdentifier ( ) ; $ identifier -> name = 'application' ; $ this -> getService ( 'anahita:loader' ) -> loadIdenti...
Loads the application .
37,646
protected function _actionPrepclienv ( AnCommandContext $ context ) { if ( ! empty ( $ _SERVER [ 'argv' ] ) && count ( $ _SERVER [ 'argv' ] ) > 1 ) { $ args = array_slice ( $ _SERVER [ 'argv' ] , 1 ) ; if ( is_readable ( realpath ( $ args [ 0 ] ) ) ) { $ file = array_shift ( $ args ) ; } $ args = explode ( '&-data&' , ...
Prepares the CLI mode .
37,647
protected function _actionDispatch ( AnCommandContext $ context ) { dispatch_plugin ( 'system.onBeforeDispatch' , array ( $ context ) ) ; $ name = 'com_' . $ this -> getComponent ( ) -> getIdentifier ( ) -> package ; define ( 'ANPATH_COMPONENT' , ANPATH_BASE . DS . 'components' . DS . $ name ) ; if ( ! file_exists ( AN...
Dispatches the component .
37,648
protected function _actionException ( $ context ) { $ exception = $ context -> data ; if ( $ exception instanceof AnException ) { $ exception = new RuntimeException ( $ exception -> getMessage ( ) , $ exception -> getCode ( ) ) ; } if ( PHP_SAPI == 'cli' ) { print "\n" ; print $ exception . "\n" ; print debug_print_bac...
Callback to handle Exception .
37,649
public function voteup ( $ voter ) { if ( $ votedown = $ this -> votedowns -> getQuery ( true ) -> disableChain ( ) -> voter ( $ voter ) -> fetch ( ) ) { $ votedown -> delete ( ) ; } else { $ voteup = $ this -> voteups -> addNew ( array ( 'voter' => $ voter , 'votee' => $ this ) ) ; if ( $ this -> isSubscribable ( ) &&...
Vote up an entity .
37,650
public function votedown ( $ voter ) { if ( $ voteup = $ this -> voteups -> getQuery ( true ) -> disableChain ( ) -> voter ( $ voter ) -> fetch ( ) ) { $ voteup -> delete ( ) ; } else { $ votedown = $ this -> votedowns -> findOrAddNew ( array ( 'voter' => $ voter , 'votee' => $ this , ) ) ; } }
Vote down an entity .
37,651
protected function _beforeEntityUpdate ( AnCommandContext $ context ) { $ modifications = $ this -> getModifiedData ( ) ; if ( isset ( $ this -> __restored ) ) { return ; } if ( $ modifications -> name || $ modifications -> body || $ modifications -> excerpt ) { $ revision = $ this -> addNewRevision ( ) ; foreach ( $ m...
Creates a new revision before updating .
37,652
public function restore ( $ revision ) { $ revision = $ this -> revisions -> find ( array ( 'revisionNum' => $ revision -> revisionNum ) ) ; if ( $ revision ) { $ this -> __restored = true ; $ this -> setData ( array ( 'name' => $ revision -> title , 'body' => $ revision -> description , 'exceprt' => $ revision -> exce...
Restore an article back to one of it s revision num .
37,653
public function addNewRevision ( ) { return $ this -> revisions -> addNew ( array ( 'component' => $ this -> component , 'author' => get_viewer ( ) , 'owner' => $ this -> owner , 'title' => $ this -> title , 'description' => $ this -> description , 'excerpt' => $ this -> excerpt , 'revisionNum' => ( int ) $ this -> rev...
Creates new revision .
37,654
public function getCoverFile ( $ size ) { if ( strpos ( $ this -> coverFilename , '/' ) ) { $ cover = str_replace ( '/' , '/covers/' . $ size , $ this -> coverFilename ) ; } else { $ cover = $ this -> component . '/covers/' . $ size . $ this -> coverFilename ; } return $ cover ; }
Return the cover file for a size .
37,655
public function getMethods ( ) { $ methods = parent :: getMethods ( ) ; $ methods = array_diff ( $ methods , $ this -> _exclude_actions ) ; return $ methods ; }
Removes the methods that are blacklisted .
37,656
protected function _actionAdd ( AnCommandContext $ context ) { $ context -> response -> status = AnHttpResponse :: CREATED ; $ entity = $ this -> getRepository ( ) -> getEntity ( ) -> setData ( $ context [ 'data' ] ) ; $ this -> setItem ( $ entity ) ; return $ this -> getItem ( ) ; }
Add Action .
37,657
protected function _commandVote ( $ command ) { $ entity = $ this -> getController ( ) -> getItem ( ) ; $ voted = $ entity -> votedUp ( get_viewer ( ) ) ; $ action = $ voted ? 'unvote' : 'vote' ; $ class = 'action-' . $ action ; if ( is ( $ entity , 'ComBaseDomainEntityComment' ) ) { $ action .= 'comment' ; $ class .= ...
Vote Command for an entity .
37,658
protected function _commandSubscribe ( $ command ) { $ entity = $ this -> getController ( ) -> getItem ( ) ; $ action = ( $ entity -> subscribed ( get_viewer ( ) ) ? 'unsubscribe' : 'subscribe' ) ; $ label = AnTranslator :: _ ( 'LIB-AN-ACTION-' . strtoupper ( $ action ) ) ; $ command -> append ( array ( 'label' => $ la...
Subscribe Action .
37,659
protected function _beforeRepositoryFetch ( AnCommandContext $ context ) { $ query = $ context -> query ; $ services = array_keys ( ComConnectHelperApi :: getServices ( ) ) ; $ query -> api ( $ services ) ; }
Modify session query to only bring the sessions that are available .
37,660
public function onStoryAggregation ( AnEvent $ event ) { if ( ! empty ( $ this -> _story_aggregation ) ) { $ event -> aggregations -> append ( array ( $ this -> component => $ this -> _story_aggregation , ) ) ; } }
Called on when the stories are being aggregated .
37,661
public function findClass ( AnServiceIdentifier $ identifier ) { $ classpath = AnInflector :: camelize ( implode ( '_' , $ identifier -> path ) ) ; $ classname = 'Plg' . ucfirst ( $ identifier -> package ) . $ classpath . ucfirst ( $ identifier -> name ) ; if ( ! class_exists ( $ classname ) ) { $ classname = false ; }...
Get the classname based on an identifier
37,662
protected function _authorizeSetPrivacyValue ( AnCommandContext $ context ) { $ value = $ context -> value ; if ( $ this -> _entity -> authorize ( 'administration' ) ) { return true ; } switch ( $ value ) { case LibBaseDomainBehaviorPrivatable :: GUEST : case LibBaseDomainBehaviorPrivatable :: REG : $ ret = true ; brea...
Check if the viewer can set certain privacy value .
37,663
protected function _authorizeAccess ( AnCommandContext $ context ) { if ( ! $ this -> _entity -> isPrivatable ( ) ) { return true ; } if ( $ this -> _viewer -> admin ( ) ) { return true ; } if ( $ this -> _entity -> isFollowable ( ) && $ this -> _entity -> blocking ( $ this -> _viewer ) ) { return false ; } if ( $ this...
Check if the actor authorize viewing a resource .
37,664
protected function _authorizeAction ( AnCommandContext $ context ) { if ( ! $ this -> _entity -> isPrivatable ( ) ) { return true ; } if ( $ this -> _viewer -> admin ( ) ) { return true ; } $ action = $ context -> action ; $ context -> append ( array ( 'default' => LibBaseDomainBehaviorPrivatable :: FOLLOWER , ) ) ; if...
Authorizes an action on resources owned by the actor .
37,665
protected function _authorizeFollower ( AnCommandContext $ context ) { if ( $ this -> _entity -> isFollowable ( ) && ! $ this -> _viewer -> isLeadable ( ) ) { return false ; } if ( $ this -> _viewer -> eql ( $ this -> _entity ) ) { return false ; } if ( is_guest ( $ this -> _viewer ) ) { return false ; } if ( ! $ this ...
If true then owner s name is visiable to the viewer if not the default name is displayed .
37,666
protected function _authorizeLead ( AnCommandContext $ context ) { if ( is_guest ( $ this -> _viewer ) ) { return false ; } if ( $ this -> _viewer -> eql ( $ this -> _entity ) ) { return false ; } if ( is_person ( $ this -> _entity ) ) { return false ; } return $ this -> _entity -> authorize ( 'action' , 'leadable:add'...
If true then the viewer can add new followers to the this actor .
37,667
protected function _authorizeUnfollow ( AnCommandContext $ context ) { if ( ! $ this -> _viewer -> following ( $ this -> _entity ) ) { return false ; } if ( $ this -> _entity -> isAdministrable ( ) && $ this -> _entity -> administratorIds -> offsetExists ( $ this -> _viewer -> id ) ) { return ( $ this -> _entity -> adm...
Checks whether the viewer can unfollow the actor .
37,668
protected function _authorizeRemoveAdmin ( AnCommandContext $ context ) { if ( $ this -> _entity -> isAdministrable ( ) ) { return ( $ this -> _entity -> administratorIds -> count ( ) >= 2 ) ; } return false ; }
Return if the viewer can remove an admin of an actor . It returns true if an actor has at least two actors .
37,669
protected function _authorizeBlock ( AnCommandContext $ context ) { if ( is_guest ( $ this -> _viewer ) ) { return false ; } if ( ! $ this -> _entity -> isLeadable ( ) ) { return false ; } if ( $ this -> _viewer -> eql ( $ this -> _entity ) ) { return false ; } if ( $ this -> _entity -> admin ( ) ) { return false ; } i...
If true then viewer can block the entity .
37,670
public function getDefaultValue ( ) { $ default = $ this -> _default ; if ( $ default && ! $ this -> isScalar ( ) ) { $ default = $ default instanceof AnDomainAttributeInterface ? clone $ default : AnDomainAttribute :: getInstance ( $ this -> _type ) ; } return $ default ; }
Clones the default value or create a new one if a type is given .
37,671
public function materialize ( array $ data , $ entity ) { $ key = $ this -> getColumn ( ) -> key ( ) ; $ value = null ; if ( $ this -> isMaterializable ( $ data ) ) { if ( ! is_null ( $ data [ $ key ] ) ) { if ( $ this -> isScalar ( ) ) { $ value = $ data [ $ key ] ; settype ( $ value , $ this -> getType ( ) ) ; } else...
Materialize the database value into attribute values for an entity .
37,672
protected function _actionEdit ( AnCommandContext $ context ) { $ data = $ context -> data ; dispatch_plugin ( 'user.onBeforeEditPerson' , array ( 'data' => $ context -> data ) ) ; $ usertype = null ; if ( $ data -> usertype ) { $ usertype = $ data -> usertype ; unset ( $ context -> data -> usertype ) ; } if ( $ data -...
Edit a person s data and synchronize with the person with the user entity .
37,673
protected function _actionSignup ( AnCommandContext $ context ) { $ data = $ context -> data ; dispatch_plugin ( 'user.onBeforeAddPerson' , array ( 'data' => $ context -> data ) ) ; $ isFirstUser = ! ( bool ) $ this -> getService ( 'repos:people.person' ) -> getQuery ( true ) -> fetchValue ( 'id' ) ; $ person = parent ...
Person signup action creates a new person object .
37,674
protected function _actionAdd ( AnCommandContext $ context ) { $ data = $ context -> data ; dispatch_plugin ( 'user.onBeforeAddPerson' , array ( 'data' => $ context -> data ) ) ; $ person = parent :: _actionAdd ( $ context ) ; $ this -> getRepository ( ) -> getValidator ( ) -> addValidation ( 'givenName' , 'required' )...
Person add action creates a new person object .
37,675
public function mailActivationLink ( AnCommandContext $ context ) { $ person = $ context -> result ; $ viewer = get_viewer ( ) ; if ( $ viewer -> admin ( ) ) { $ subject = 'COM-PEOPLE-MAIL-SUBJECT-ACCOUNT-CREATED' ; $ template = 'account_created' ; } else { $ subject = 'COM-PEOPLE-MAIL-SUBJECT-ACCOUNT-ACTIVATE' ; $ tem...
Mail an activation link .
37,676
public function mailAdminsNewAdmin ( AnCommandContext $ context ) { $ person = $ context -> result ; $ this -> mailAdmins ( array ( 'subject' => AnTranslator :: sprintf ( 'COM-PEOPLE-MAIL-SUBJECT-NEW-ADMIN' , $ person -> name ) , 'template' => 'new_admin' , ) ) ; }
Notify admins that a new admin has joined the network .
37,677
public function activateFirstAdmin ( AnCommandContext $ context ) { $ person = $ context -> result ; $ url = route ( 'option=com_people&view=session&isFirstPerson=1&token=' . $ person -> activationCode ) ; $ context -> response -> setRedirect ( $ url ) ; }
Autologin the first user which is also the first super admin .
37,678
public function onSettingDisplay ( AnEvent $ event ) { $ tabs = $ event -> tabs ; $ viewer = get_viewer ( ) ; if ( $ viewer -> admin ( ) || $ viewer -> eql ( $ this -> getItem ( ) ) ) { $ tabs -> insert ( 'account' , array ( 'label' => AnTranslator :: _ ( 'COM-PEOPLE-SETTING-TAB-ACCOUNT' ) ) ) ; } }
Called before the setting page is displayed .
37,679
public function addMentionsFromBody ( ) { $ entity = $ this -> getItem ( ) ; $ usernames = $ this -> extractMentions ( $ entity -> body ) ; foreach ( $ usernames as $ username ) { $ entity -> addMention ( trim ( $ username ) ) ; } $ this -> _newly_mentioned = $ usernames ; }
Extracts mention usernames from the entity body and add them to the item .
37,680
public function updateMentionsFromBody ( AnCommandContext $ context ) { $ entity = $ this -> getItem ( ) ; $ body_mentions = $ this -> extractMentions ( $ entity -> body ) ; $ body_mentions = array_map ( 'strtolower' , $ body_mentions ) ; $ entity_mentions = AnConfig :: unbox ( $ entity -> mentions -> alias ) ; if ( is...
Extracts mention usernames from the entity body and updates the entity .
37,681
public function extractMentions ( $ text ) { $ matches = array ( ) ; if ( preg_match_all ( ComPeopleDomainEntityPerson :: PATTERN_MENTION , $ text , $ matches ) ) { return array_unique ( $ matches [ 1 ] ) ; } else { return array ( ) ; } }
extracts a list of mention usernames from a given text .
37,682
public function notifyMentioned ( AnCommandContext $ context ) { $ entity = $ this -> getItem ( ) ; $ subscribers = array ( ) ; foreach ( $ this -> _newly_mentioned as $ username ) { $ person = $ this -> getService ( 'repos:people.person' ) -> find ( array ( 'username' => $ username ) ) ; if ( $ person && $ person -> a...
Notify the people who have been mentioned .
37,683
public function flash ( $ config = array ( ) ) { $ data = $ this -> _template -> getData ( ) ; if ( isset ( $ data [ 'flash' ] ) && $ data [ 'flash' ] -> message ) { $ message = array_merge ( ( array ) $ data [ 'flash' ] -> getMessage ( true ) , $ config ) ; return $ this -> message ( $ message [ 'message' ] , $ messag...
Render the message in the flash .
37,684
public function message ( $ message , $ config = array ( ) ) { $ config = new AnConfig ( $ config ) ; $ config -> append ( array ( 'type' => 'info' , 'block' => true , 'closable' => false , ) ) ; $ alertblock = ( $ config -> block ) ? 'alert-block' : '' ; $ close_handler = '' ; if ( $ config -> closable ) { $ close_han...
Renders a message .
37,685
public function dropdown ( $ commands , $ config = array ( ) ) { $ config [ 'commands' ] = $ commands ; if ( ! isset ( $ config [ 'icon' ] ) ) { $ config [ 'icon' ] = 'cog' ; } return $ this -> _render ( 'dropdown' , $ config ) ; }
Creates a dropdown from a list of commands .
37,686
public function comments ( $ entity , $ config = array ( ) ) { $ config = array_merge ( array ( 'truncate_body' => array ( ) , 'editor' => false , 'pagination' => true , 'show_guest_prompt' => true , 'content_filter_exclude' => array ( ) , ) , $ config ) ; $ data = $ this -> getTemplate ( ) -> getData ( ) ; $ limit = i...
Renders the comments for a commentable .
37,687
public function command ( $ command ) { $ attributes = AnConfig :: unbox ( $ command -> getAttributes ( ) ) ; if ( isset ( $ attributes [ 'icon' ] ) ) { $ icon = 'icon-' . $ attributes [ 'icon' ] ; $ command -> label = '<i class="' . $ icon . '"></i>&nbsp;' . $ command -> label ; unset ( $ attributes [ 'icon' ] ) ; } $...
Renders a command as a link tag . If it has a href it will use the route to Route the link .
37,688
public function voters ( $ entity , $ config = array ( ) ) { $ viewer = $ this -> getService ( 'com:people.viewer' ) ; $ config = array_merge ( array ( 'avatars' => false , 'viewer' => $ viewer , ) , $ config ) ; if ( ! $ config [ 'avatars' ] ) { return $ this -> _render ( 'voters' , array ( 'entity' => $ entity , 'vie...
Renders a list of voters for an entity .
37,689
public function infinitescroll ( $ entities , $ config = array ( ) ) { $ config = array_merge ( array ( 'entities' => ( isset ( $ entities ) ) ? $ entities : null , 'filter' => null , 'entity_type' => ( isset ( $ entities ) ) ? $ entities -> getIdentifier ( ) -> name : null , 'id' => null , 'columns' => 2 , 'layout_lis...
Renders an InfinitScroll and Masonry layout if there are more than one columns
37,690
public function pagination ( $ paginator , $ config = array ( ) ) { if ( ! $ paginator ) { return '' ; } $ config = new AnConfig ( $ config ) ; $ config -> append ( array ( 'url' => ( string ) $ this -> _template -> getView ( ) -> getRoute ( ) , 'force' => false , 'options' => array ( 'limit' => 20 , ) , ) ) ; if ( is ...
Renders a pagination using the paginator object .
37,691
public function editor ( $ config ) { $ config = new AnConfig ( $ config ) ; $ config -> append ( array ( 'name' => 'description' , 'content' => '' , 'value' => '' , ) ) ; $ config -> append ( array ( 'html' => array ( 'id' => $ config -> name , 'width' => '100%' , 'height' => '500' , 'cols' => '75' , 'rows' => '20' , ...
Renders an editor .
37,692
public function filterbox ( $ path , $ config = array ( ) ) { if ( is_array ( $ path ) ) { $ path = $ this -> _template -> getView ( ) -> getRoute ( $ path ) ; } $ uri = $ this -> getService ( 'anahita:http.url' , array ( 'url' => $ path ) ) ; $ data = $ uri -> getQuery ( true ) ; unset ( $ data [ 'q' ] ) ; $ uri -> se...
Renders a filterbox .
37,693
public function search ( $ config = array ( ) ) { $ actor = null ; $ label = AnTranslator :: _ ( 'LIB-AN-SEARCH-PLACEHOLDER' ) ; if ( $ this -> getService ( ) -> has ( 'com:search.owner' ) ) { $ actor = $ this -> getService ( 'com:search.owner' ) ; $ label = AnTranslator :: sprintf ( 'LIB-AN-SEARCH-PLACEHOLDER-OWNER' ,...
Renders a search .
37,694
protected function _render ( $ ui , $ data = array ( ) ) { $ data [ 'helper' ] = $ this ; $ file = '_ui_' . $ ui . '.php' ; $ data = AnConfig :: unbox ( $ data ) ; return ( string ) $ this -> _template -> loadTemplate ( '_ui_' . $ ui , $ data ) ; }
Renders a string using the template . We are using loadString as opposed to loadTempalte or loadFile in order to avoid changing the state of the template .
37,695
public static function verbalize ( $ word ) { if ( isset ( self :: $ _cache [ 'verbalized' ] [ $ word ] ) ) { return self :: $ _cache [ 'verbalized' ] [ $ word ] ; } foreach ( self :: $ _rules [ 'verbalization' ] as $ regexp => $ replacement ) { $ matches = null ; $ verbal = preg_replace ( $ regexp , $ replacement , $ ...
Present English verb conjugated to preterite participle .
37,696
public static function camelize ( $ word ) { $ word = preg_replace ( '/[^a-zA-Z0-9\s]/' , ' ' , $ word ) ; $ word = str_replace ( ' ' , '' , ucwords ( strtolower ( str_replace ( '_' , ' ' , $ word ) ) ) ) ; return $ word ; }
Returns given word as CamelCased
37,697
public static function tableize ( $ className ) { $ result = self :: underscore ( $ className ) ; if ( ! self :: isPlural ( $ className ) ) { $ result = self :: pluralize ( $ result ) ; } return $ result ; }
Converts a class name to its table name according to Anahita naming conventions .
37,698
public static function variablize ( $ string ) { $ string = self :: camelize ( self :: underscore ( $ string ) ) ; $ result = strtolower ( substr ( $ string , 0 , 1 ) ) ; $ variable = preg_replace ( '/\\w/' , $ result , $ string , 1 ) ; return $ variable ; }
Returns camelBacked version of a string .
37,699
public static function isSingular ( $ string ) { $ singular = isset ( self :: $ _cache [ 'singularized' ] [ $ string ] ) ? self :: $ _cache [ 'singularized' ] [ $ string ] : null ; $ plural = $ singular && isset ( self :: $ _cache [ 'pluralized' ] [ $ singular ] ) ? self :: $ _cache [ 'pluralized' ] [ $ singular ] : nu...
Check to see if an English word is singular