Class pendalf89\filemanager\models\Mediafile
This is the model class for table "filemanager_mediafile".
Public Properties
Protected Properties
Property | Type | Description | Defined By |
---|---|---|---|
$tagIds | array|null | pendalf89\filemanager\models\Mediafile |
Public Methods
Method | Description | Defined By |
---|---|---|
__call() | Calls the named method which is not a class method. | yii\base\Component |
__clone() | This method is called after the object is created by cloning an existing one. | yii\base\Component |
__construct() | Constructor. | yii\base\Object |
__get() | PHP getter magic method. | yii\db\BaseActiveRecord |
__isset() | Checks if a property value is null. | yii\db\BaseActiveRecord |
__set() | PHP setter magic method. | yii\db\BaseActiveRecord |
__unset() | Sets a component property to be null. | yii\db\BaseActiveRecord |
activeAttributes() | Returns the attribute names that are subject to validation in the current scenario. | yii\base\Model |
addError() | Adds a new error to the specified attribute. | yii\base\Model |
addErrors() | Adds a list of errors. | yii\base\Model |
addOwner() | Add owner to mediafiles table | pendalf89\filemanager\models\Mediafile |
afterDelete() | pendalf89\filemanager\models\Mediafile | |
afterFind() | This method is called when the AR object is created and populated with the query result. | yii\db\BaseActiveRecord |
afterRefresh() | This method is called when the AR object is refreshed. | yii\db\BaseActiveRecord |
afterSave() | pendalf89\filemanager\models\Mediafile | |
afterValidate() | This method is invoked after validation ends. | yii\base\Model |
attachBehavior() | Attaches a behavior to this component. | yii\base\Component |
attachBehaviors() | Attaches a list of behaviors to the component. | yii\base\Component |
attributeHints() | Returns the attribute hints. | yii\base\Model |
attributeLabels() | Returns the attribute labels. | pendalf89\filemanager\models\Mediafile |
attributes() | Returns the list of all attribute names of the model. | yii\db\ActiveRecord |
beforeDelete() | pendalf89\filemanager\models\Mediafile | |
beforeSave() | This method is called at the beginning of inserting or updating a record. | yii\db\BaseActiveRecord |
beforeValidate() | This method is invoked before validation starts. | yii\base\Model |
behaviors() | Returns a list of behaviors that this component should behave as. | pendalf89\filemanager\models\Mediafile |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\db\BaseActiveRecord |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\db\BaseActiveRecord |
className() | Returns the fully qualified name of this class. | yii\base\Object |
clearErrors() | Removes errors for all attributes or a single attribute. | yii\base\Model |
createDefaultThumb() | Create default thumbnail | pendalf89\filemanager\models\Mediafile |
createThumbs() | Create thumbs for this image | pendalf89\filemanager\models\Mediafile |
createValidators() | Creates validator objects based on the validation rules specified in rules(). | yii\base\Model |
delete() | Deletes the table row corresponding to this active record. | yii\db\ActiveRecord |
deleteAll() | Deletes rows in the table using the provided conditions. | yii\db\ActiveRecord |
deleteFile() | Delete file | pendalf89\filemanager\models\Mediafile |
deleteThumbs() | Delete thumbnails for current image | pendalf89\filemanager\models\Mediafile |
detachBehavior() | Detaches a behavior from the component. | yii\base\Component |
detachBehaviors() | Detaches all behaviors from the component. | yii\base\Component |
ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\base\Component |
equals() | Returns a value indicating whether the given active record is the same as the current one. | yii\db\ActiveRecord |
extraFields() | Returns the list of fields that can be expanded further and returned by toArray(). | yii\base\ArrayableTrait |
fields() | Returns the list of fields that should be returned by default by toArray() when no specific fields are specified. | yii\base\ArrayableTrait |
find() | Creates an yii\db\ActiveQueryInterface instance for query purpose. | yii\db\ActiveRecord |
findAll() | Returns a list of active record models that match the specified primary key value(s) or a set of column values. | yii\db\BaseActiveRecord |
findBySql() | Creates an yii\db\ActiveQuery instance with a given SQL statement. | yii\db\ActiveRecord |
findByTypes() | Search models by file types | pendalf89\filemanager\models\Mediafile |
findByUrl() | Find model by url | pendalf89\filemanager\models\Mediafile |
findOne() | Returns a single active record model instance by a primary key or an array of column values. | yii\db\BaseActiveRecord |
formName() | Returns the form name that this model class should use. | yii\base\Model |
generateAttributeLabel() | Generates a user friendly attribute label based on the give attribute name. | yii\base\Model |
getActiveValidators() | Returns the validators applicable to the current $scenario. | yii\base\Model |
getAttribute() | Returns the named attribute value. | yii\db\BaseActiveRecord |
getAttributeHint() | Returns the text hint for the specified attribute. | yii\db\BaseActiveRecord |
getAttributeLabel() | Returns the text label for the specified attribute. | yii\db\BaseActiveRecord |
getAttributes() | Returns attribute values. | yii\base\Model |
getBehavior() | Returns the named behavior object. | yii\base\Component |
getBehaviors() | Returns all behaviors attached to this component. | yii\base\Component |
getDb() | Returns the database connection used by this AR class. | yii\db\ActiveRecord |
getDefaultThumbUrl() | pendalf89\filemanager\models\Mediafile | |
getDefaultUploadThumbUrl() | pendalf89\filemanager\models\Mediafile | |
getDirtyAttributes() | Returns the attribute values that have been modified since they are loaded or saved most recently. | yii\db\BaseActiveRecord |
getErrors() | Returns the errors for all attributes or a single attribute. | yii\base\Model |
getFileSize() | pendalf89\filemanager\models\Mediafile | |
getFirstError() | Returns the first error of the specified attribute. | yii\base\Model |
getFirstErrors() | Returns the first error of every attribute in the model. | yii\base\Model |
getImagesList() | pendalf89\filemanager\models\Mediafile | |
getIsNewRecord() | Returns a value indicating whether the current record is new. | yii\db\BaseActiveRecord |
getIterator() | Returns an iterator for traversing the attributes in the model. | yii\base\Model |
getLastChanges() | pendalf89\filemanager\models\Mediafile | |
getOldAttribute() | Returns the old value of the named attribute. | yii\db\BaseActiveRecord |
getOldAttributes() | Returns the old attribute values. | yii\db\BaseActiveRecord |
getOldPrimaryKey() | Returns the old primary key value(s). | yii\db\BaseActiveRecord |
getOriginalImageSize() | This method wrap getimagesize() function | pendalf89\filemanager\models\Mediafile |
getOriginalImageSizes() | This method wrap getimagesize() function | pendalf89\filemanager\models\Mediafile |
getOwners() | pendalf89\filemanager\models\Mediafile | |
getPrimaryKey() | Returns the primary key value(s). | yii\db\BaseActiveRecord |
getRelatedRecords() | Returns all populated related records. | yii\db\BaseActiveRecord |
getRelation() | Returns the relation object with the specified name. | yii\db\BaseActiveRecord |
getScenario() | Returns the scenario that this model is used in. | yii\base\Model |
getTableSchema() | Returns the schema information of the DB table associated with this AR class. | yii\db\ActiveRecord |
getTagIds() | pendalf89\filemanager\models\Mediafile | |
getTags() | pendalf89\filemanager\models\Mediafile | |
getThumbImage() | Thumbnail image html tag | pendalf89\filemanager\models\Mediafile |
getThumbUrl() | pendalf89\filemanager\models\Mediafile | |
getThumbs() | pendalf89\filemanager\models\Mediafile | |
getValidators() | Returns all the validators declared in rules(). | yii\base\Model |
hasAttribute() | Returns a value indicating whether the model has an attribute with the specified name. | yii\db\BaseActiveRecord |
hasErrors() | Returns a value indicating whether there is any validation error. | yii\base\Model |
hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. | yii\base\Component |
hasMany() | Declares a has-many relation. |
yii\db\BaseActiveRecord |
hasMethod() | Returns a value indicating whether a method is defined. | yii\base\Component |
hasOne() | Declares a has-one relation. |
yii\db\BaseActiveRecord |
hasProperty() | Returns a value indicating whether a property is defined for this component. | yii\base\Component |
init() | Initializes the object. | pendalf89\filemanager\models\Mediafile |
insert() | Inserts a row into the associated database table using the attribute values of this record. | yii\db\ActiveRecord |
instantiate() | Creates an active record instance. | yii\db\BaseActiveRecord |
isAttributeActive() | Returns a value indicating whether the attribute is active in the current scenario. | yii\base\Model |
isAttributeChanged() | Returns a value indicating whether the named attribute has been changed. | yii\db\BaseActiveRecord |
isAttributeRequired() | Returns a value indicating whether the attribute is required. | yii\base\Model |
isAttributeSafe() | Returns a value indicating whether the attribute is safe for massive assignments. | yii\base\Model |
isImage() | pendalf89\filemanager\models\Mediafile | |
isPrimaryKey() | Returns a value indicating whether the given set of attributes represents the primary key for this model | yii\db\BaseActiveRecord |
isRelationPopulated() | Check whether the named relation has been populated with records. | yii\db\BaseActiveRecord |
isTransactional() | Returns a value indicating whether the specified operation is transactional in the current $scenario. | yii\db\ActiveRecord |
link() | Establishes the relationship between two models. | yii\db\BaseActiveRecord |
load() | Populates the model with input data. | yii\base\Model |
loadDefaultValues() | Loads default values from database table schema | yii\db\ActiveRecord |
loadMultiple() | Populates a set of models with the data from end user. | yii\base\Model |
loadOneByOwner() | pendalf89\filemanager\models\Mediafile | |
markAttributeDirty() | Marks an attribute dirty. | yii\db\BaseActiveRecord |
off() | Detaches an existing event handler from this component. | yii\base\Component |
offsetExists() | Returns whether there is an element at the specified offset. | yii\db\BaseActiveRecord |
offsetGet() | Returns the element at the specified offset. | yii\base\Model |
offsetSet() | Sets the element at the specified offset. | yii\base\Model |
offsetUnset() | Sets the element value at the specified offset to null. | yii\db\BaseActiveRecord |
on() | Attaches an event handler to an event. | yii\base\Component |
onUnsafeAttribute() | This method is invoked when an unsafe attribute is being massively assigned. | yii\base\Model |
optimisticLock() | Returns the name of the column that stores the lock version for implementing optimistic locking. | yii\db\BaseActiveRecord |
populateRecord() | Populates an active record object using a row of data from the database/storage. | yii\db\ActiveRecord |
populateRelation() | Populates the named relation with the related records. | yii\db\BaseActiveRecord |
primaryKey() | Returns the primary key name(s) for this AR class. | yii\db\ActiveRecord |
refresh() | Repopulates this active record with the latest data. | yii\db\BaseActiveRecord |
removeOwner() | Remove this mediafile owner | pendalf89\filemanager\models\Mediafile |
rules() | Returns the validation rules for attributes. | pendalf89\filemanager\models\Mediafile |
safeAttributes() | Returns the attribute names that are safe to be massively assigned in the current scenario. | yii\base\Model |
save() | Saves the current record. | yii\db\BaseActiveRecord |
saveUploadedFile() | Save just uploaded file | pendalf89\filemanager\models\Mediafile |
scenarios() | Returns a list of scenarios and the corresponding active attributes. | yii\base\Model |
setAttribute() | Sets the named attribute value. | yii\db\BaseActiveRecord |
setAttributes() | Sets the attribute values in a massive way. | yii\base\Model |
setIsNewRecord() | Sets the value indicating whether the record is new. | yii\db\BaseActiveRecord |
setOldAttribute() | Sets the old value of the named attribute. | yii\db\BaseActiveRecord |
setOldAttributes() | Sets the old attribute values. | yii\db\BaseActiveRecord |
setScenario() | Sets the scenario for the model. | yii\base\Model |
setTagIds() | pendalf89\filemanager\models\Mediafile | |
tableName() | Declares the name of the database table associated with this AR class. | pendalf89\filemanager\models\Mediafile |
toArray() | Converts the model into an array. | yii\base\ArrayableTrait |
transactions() | Declares which DB operations should be performed within a transaction in different scenarios. | yii\db\ActiveRecord |
trigger() | Triggers an event. | yii\base\Component |
unlink() | Destroys the relationship between two models. | yii\db\BaseActiveRecord |
unlinkAll() | Destroys the relationship in current model. | yii\db\BaseActiveRecord |
update() | Saves the changes to this active record into the associated database table. | yii\db\ActiveRecord |
updateAll() | Updates the whole table using the provided attribute values and conditions. | yii\db\ActiveRecord |
updateAllCounters() | Updates the whole table using the provided counter changes and conditions. | yii\db\ActiveRecord |
updateAttributes() | Updates the specified attributes. | yii\db\BaseActiveRecord |
updateCounters() | Updates one or several counter columns for the current AR object. | yii\db\BaseActiveRecord |
validate() | Performs the data validation. | yii\base\Model |
validateMultiple() | Validates multiple models. | yii\base\Model |
Protected Methods
Method | Description | Defined By |
---|---|---|
createRelationQuery() | Creates a query instance for has-one or has-many relation. |
yii\db\BaseActiveRecord |
deleteInternal() | Deletes an ActiveRecord without considering transaction. | yii\db\ActiveRecord |
findByCondition() | Finds ActiveRecord instance(s) by the given condition. | yii\db\ActiveRecord |
getThumbFilename() | Returns thumbnail name | pendalf89\filemanager\models\Mediafile |
insertInternal() | Inserts an ActiveRecord into DB without considering transaction. | yii\db\ActiveRecord |
resolveFields() | Determines which fields can be returned by toArray(). | yii\base\ArrayableTrait |
updateInternal() | yii\db\BaseActiveRecord |
Events
Event | Type | Description | Defined By |
---|---|---|---|
EVENT_AFTER_DELETE | yii\base\Event | An event that is triggered after a record is deleted. | yii\db\BaseActiveRecord |
EVENT_AFTER_FIND | yii\base\Event | An event that is triggered after the record is created and populated with query result. | yii\db\BaseActiveRecord |
EVENT_AFTER_INSERT | yii\db\AfterSaveEvent | An event that is triggered after a record is inserted. | yii\db\BaseActiveRecord |
EVENT_AFTER_REFRESH | yii\base\Event | An event that is triggered after a record is refreshed. (available since version 2.0.8) | yii\db\BaseActiveRecord |
EVENT_AFTER_UPDATE | yii\db\AfterSaveEvent | An event that is triggered after a record is updated. | yii\db\BaseActiveRecord |
EVENT_AFTER_VALIDATE | yii\base\Event | An event raised at the end of validate() | yii\base\Model |
EVENT_BEFORE_DELETE | yii\base\ModelEvent | An event that is triggered before deleting a record. | yii\db\BaseActiveRecord |
EVENT_BEFORE_INSERT | yii\base\ModelEvent | An event that is triggered before inserting a record. | yii\db\BaseActiveRecord |
EVENT_BEFORE_UPDATE | yii\base\ModelEvent | An event that is triggered before updating a record. | yii\db\BaseActiveRecord |
EVENT_BEFORE_VALIDATE | yii\base\ModelEvent | An event raised at the beginning of validate(). | yii\base\Model |
EVENT_INIT | yii\base\Event | An event that is triggered when the record is initialized via init(). | yii\db\BaseActiveRecord |
Constants
Constant | Value | Description | Defined By |
---|---|---|---|
OP_ALL | 7 | All three operations: insert, update, delete. This is a shortcut of the expression: OP_INSERT | OP_UPDATE | OP_DELETE. | yii\db\ActiveRecord |
OP_DELETE | 4 | The delete operation. This is mainly used when overriding transactions() to specify which operations are transactional. | yii\db\ActiveRecord |
OP_INSERT | 1 | The insert operation. This is mainly used when overriding transactions() to specify which operations are transactional. | yii\db\ActiveRecord |
OP_UPDATE | 2 | The update operation. This is mainly used when overriding transactions() to specify which operations are transactional. | yii\db\ActiveRecord |
SCENARIO_DEFAULT | 'default' | The name of the default scenario. | yii\base\Model |
Property Details
Default thumbnail for image
Default thumbnail for image
File size
Last changes timestamp
Thumbnails
Method Details
Add owner to mediafiles table
public boolean addOwner ( $owner_id, $owner, $owner_attribute ) | ||
$owner_id | integer | Owner id |
$owner | string | Owner identification name |
$owner_attribute | string | Owner identification attribute |
return | boolean | Save result |
---|
public void afterDelete ( ) |
public void afterSave ( $insert, $changedAttributes ) | ||
$insert | ||
$changedAttributes |
Returns the attribute labels.
Attribute labels are mainly used for display purpose. For example, given an attribute
firstName
, we can declare a label First Name
which is more user-friendly and can
be displayed to end users.
By default an attribute label is generated using generateAttributeLabel(). This method allows you to explicitly specify attribute labels.
Note, in order to inherit labels defined in the parent class, a child class needs to
merge the parent labels with child labels using functions such as array_merge()
.
public array attributeLabels ( ) | ||
return | array | Attribute labels (name => label) |
---|
public void beforeDelete ( ) |
Returns a list of behaviors that this component should behave as.
Child classes may override this method to specify the behaviors they want to behave as.
The return value of this method should be an array of behavior objects or configurations indexed by behavior names. A behavior configuration can be either a string specifying the behavior class or an array of the following structure:
'behaviorName' => [
'class' => 'BehaviorClass',
'property1' => 'value1',
'property2' => 'value2',
]
Note that a behavior class must extend from \pendalf89\filemanager\models\Behavior. Behaviors can be attached using a name or anonymously. When a name is used as the array key, using this name, the behavior can later be retrieved using getBehavior() or be detached using detachBehavior(). Anonymous behaviors can not be retrieved or detached.
Behaviors declared in this method will be attached to the component automatically (on demand).
public array behaviors ( ) | ||
return | array | The behavior configurations. |
---|
Create default thumbnail
public void createDefaultThumb ( array $routes ) | ||
$routes | array | See routes in module config |
Create thumbs for this image
public boolean createThumbs ( array $routes, array $presets ) | ||
$routes | array | See routes in module config |
$presets | array | Thumbs presets. See in module config |
Delete file
public boolean deleteFile ( array $routes ) | ||
$routes | array | See routes in module config |
Delete thumbnails for current image
public void deleteThumbs ( array $routes ) | ||
$routes | array | See routes in module config |
Search models by file types
public static array|yii\db\ActiveRecord[] findByTypes ( array $types ) | ||
$types | array | File types |
Find model by url
public static static findByUrl ( $url ) | ||
$url |
public string getDefaultThumbUrl ( $baseUrl = '' ) | ||
$baseUrl | ||
return | string | Default thumbnail for image |
---|
public string getDefaultUploadThumbUrl ( $baseUrl = '' ) | ||
$baseUrl | ||
return | string | Default thumbnail for image |
---|
public string getFileSize ( ) | ||
return | string | File size |
---|
public array getImagesList ( pendalf89\filemanager\Module $module ) | ||
$module | pendalf89\filemanager\Module | |
return | array | Images list |
---|
public integer getLastChanges ( ) | ||
return | integer | Last changes timestamp |
---|
This method wrap getimagesize() function
public string getOriginalImageSize ( array $routes, $delimiter = ' × ' ) | ||
$routes | array | See routes in module config |
$delimiter | string | Delimiter between width and height |
return | string | Image size like '1366x768' |
---|
This method wrap getimagesize() function
public array getOriginalImageSizes ( array $routes ) | ||
$routes | array | See routes in module config |
public yii\db\ActiveQuery getOwners ( ) |
public array|null getTagIds ( ) |
public yii\db\ActiveQuery getTags ( ) |
Returns thumbnail name
protected string getThumbFilename ( $original, $extension, $alias, $width, $height ) | ||
$original | ||
$extension | ||
$alias | ||
$width | ||
$height |
Thumbnail image html tag
public string getThumbImage ( $alias, $options = [] ) | ||
$alias | string | Thumbnail alias |
$options | array | Html options |
return | string | Html image tag |
---|
public string getThumbUrl ( $alias ) | ||
$alias | string | Thumb alias |
return | string | Thumb url |
---|
public array getThumbs ( ) | ||
return | array | Thumbnails |
---|
Initializes the object.
This method is called at the end of the constructor. The default implementation will trigger an EVENT_INIT event. If you override this method, make sure you call the parent implementation at the end to ensure triggering of the event.
public void init ( ) |
public boolean isImage ( ) | ||
return | boolean | If type of this media file is image, return true; |
---|
public static void loadOneByOwner ( $owner, $owner_id, $owner_attribute ) | ||
$owner | ||
$owner_id | ||
$owner_attribute |
Remove this mediafile owner
public static boolean removeOwner ( $owner_id, $owner, $owner_attribute ) | ||
$owner_id | integer | Owner id |
$owner | string | Owner identification name |
$owner_attribute | string | Owner identification attribute |
return | boolean | Delete result |
---|
Returns the validation rules for attributes.
Validation rules are used by validate() to check if attribute values are valid. Child classes may override this method to declare different validation rules.
Each rule is an array with the following structure:
[
['attribute1', 'attribute2'],
'validator type',
'on' => ['scenario1', 'scenario2'],
//...other parameters...
]
where
- attribute list: required, specifies the attributes array to be validated, for single attribute you can pass a string;
- validator type: required, specifies the validator to be used. It can be a built-in validator name, a method name of the model class, an anonymous function, or a validator class name.
- on: optional, specifies the scenarios array in which the validation rule can be applied. If this option is not set, the rule will apply to all scenarios.
- additional name-value pairs can be specified to initialize the corresponding validator properties. Please refer to individual validator class API for possible properties.
A validator can be either an object of a class extending \pendalf89\filemanager\models\Validator, or a model class method (called inline validator) that has the following signature:
// $params refers to validation parameters given in the rule
function validatorName($attribute, $params)
In the above $attribute
refers to the attribute currently being validated while $params
contains an array of
validator configuration options such as max
in case of string
validator. The value of the attribute currently being validated
can be accessed as $this->$attribute
. Note the $
before attribute
; this is taking the value of the variable
$attribute
and using it as the name of the property to access.
Yii also provides a set of \pendalf89\filemanager\models\Validator::builtInValidators. Each one has an alias name which can be used when specifying a validation rule.
Below are some examples:
[
// built-in "required" validator
[['username', 'password'], 'required'],
// built-in "string" validator customized with "min" and "max" properties
['username', 'string', 'min' => 3, 'max' => 12],
// built-in "compare" validator that is used in "register" scenario only
['password', 'compare', 'compareAttribute' => 'password2', 'on' => 'register'],
// an inline validator defined via the "authenticate()" method in the model class
['password', 'authenticate', 'on' => 'login'],
// a validator of class "DateRangeValidator"
['dateRange', 'DateRangeValidator'],
];
Note, in order to inherit rules defined in the parent class, a child class needs to
merge the parent rules with child rules using functions such as array_merge()
.
public array rules ( ) | ||
return | array | Validation rules |
---|
Save just uploaded file
public boolean saveUploadedFile ( array $routes, $rename = false ) | ||
$routes | array | Routes from module settings |
$rename | boolean |
public void setTagIds ( $value ) | ||
$value |
Declares the name of the database table associated with this AR class.
By default this method returns the class name as the table name by calling yii\helpers\Inflector::camel2id()
with prefix \pendalf89\filemanager\models\Connection::tablePrefix. For example if \pendalf89\filemanager\models\Connection::tablePrefix is tbl_
,
Customer
becomes tbl_customer
, and OrderItem
becomes tbl_order_item
. You may override this method
if the table is not named after this convention.
public static string tableName ( ) | ||
return | string | The table name |
---|