WikiThumbDetailJob
extends MediaJob
in package
A media job to add thumbnails and animated thumbnails for wiki page media resources that have just been viewed in the browser. This is detected by the method: GroupModel::getGroupPageResourceUrls which write a file GroupModel::NEEDS_THUMBS_DIR . L\crawlHash($folder) . ".txt" to with information about the folders needing thumbs.
Table of Contents
- $controller : object
- If MediaJob was instantiated in the web app, the controller that instatiated it
- $group_model : GroupModel
- Model responsible for getting and retrieval Wiki info for this instance of Yioop
- $media_updater : object
- If the MediaJob was instantiated in a MediaUpdater, this is a reference to that updater
- $name_server_does_client_tasks : bool
- Whether to run the job's client tasks on the name server in addition to prepareTasks and finishTasks
- $name_server_does_client_tasks_only : bool
- Whether this MediaJob performs name server only tasks
- $tasks : array<string|int, mixed>
- The most recently received from the name server tasks for this MediaJob
- $update_time : int
- Time last checked if there were folders missing thumbs
- __construct() : mixed
- Instiates the MediaJob with a reference to the object that instatiated it
- checkPrerequisites() : bool
- Only update if its been more than CWIKI_UPDATE_INTERVAL since the last update (default one minute)
- doTasks() : mixed
- Given a list of file names of file containing information about which folders need thumbs, reads in those files, and generates thumbs for the corresponding folders.
- execNameServer() : array<string|int, mixed>
- Executes a method on the name server's JobController.
- finishTasks() : mixed
- This method is called on the name server to finish processing any data returned by MediaUpdater clients.
- generateThumbs() : mixed
- Used to generate in $thumb_folder all the missing thumbnails for resources in $folder
- getCurrentMachine() : string
- Returns a hash of the url of the current machine based on the value saved to self::current_machine_info_file by a machine statuses request
- getJobName() : string
- Gets the class name (less namespace and the word Job ) of the current MediaJob
- getTasks() : array<string|int, mixed>
- Method called from JobController when a MediaUpdater client contacts the name server's web app. This method is supposed to marshal any data on the name server that the requesting client should process.
- init() : mixed
- Initializes the last update time to far in the past so, missing thumb folders will get processed immediately when MediaUpdater first run.
- nondistributedTasks() : mixed
- Gets all folder files describing Wiki pages with resources that need thumbs. Then creates thumbs for them. Since the wiki is only on the name server all tasks will be nondistributedTasks.
- prepareTasks() : mixed
- This method is called on the name server to prepare data for any MediaUpdater clients.
- putTasks() : array<string|int, mixed>
- After a MediaUpdater client is done with the task given to it by the name server's media updater, the client contact the name server's web app. The name servers web app's JobController then calls this method to receive the data on the name server
- run() : mixed
- Method executed by MediaUpdater to perform the MediaJob. This method shouldn't need to be overridden. Instead, the various callbacks it calls (listed in the class description) wshould be overridden.
Properties
$controller
If MediaJob was instantiated in the web app, the controller that instatiated it
public
object
$controller
$group_model
Model responsible for getting and retrieval Wiki info for this instance of Yioop
public
GroupModel
$group_model
$media_updater
If the MediaJob was instantiated in a MediaUpdater, this is a reference to that updater
public
object
$media_updater
$name_server_does_client_tasks
Whether to run the job's client tasks on the name server in addition to prepareTasks and finishTasks
public
bool
$name_server_does_client_tasks
$name_server_does_client_tasks_only
Whether this MediaJob performs name server only tasks
public
bool
$name_server_does_client_tasks_only
$tasks
The most recently received from the name server tasks for this MediaJob
public
array<string|int, mixed>
$tasks
$update_time
Time last checked if there were folders missing thumbs
public
int
$update_time
Methods
__construct()
Instiates the MediaJob with a reference to the object that instatiated it
public
__construct([object $media_updater = null ][, object $controller = null ]) : mixed
Parameters
- $media_updater : object = null
-
a reference to the media updater that instatiated this object (if being run in MediaUpdater)
- $controller : object = null
-
a reference to the controller that instantiated this object (if being run in the web app)
Return values
mixed —checkPrerequisites()
Only update if its been more than CWIKI_UPDATE_INTERVAL since the last update (default one minute)
public
checkPrerequisites() : bool
Return values
bool —whether its been an hour since the last update
doTasks()
Given a list of file names of file containing information about which folders need thumbs, reads in those files, and generates thumbs for the corresponding folders.
public
doTasks(array<string|int, mixed> $tasks) : mixed
Parameters
- $tasks : array<string|int, mixed>
-
a list of filenames containing folder names of Yioop wiki folders that need thumbs
Return values
mixed —the result of carrying out that processing
execNameServer()
Executes a method on the name server's JobController.
public
static execNameServer(string $command[, string $args = null ]) : array<string|int, mixed>
It will typically execute either getTask or putTask for a specific Mediajob or getUpdateProperties to find out the current MediaUpdater should be configured.
Parameters
- $command : string
-
the method to invoke on the name server
- $args : string = null
-
additional arguments to be passed to the name server
Return values
array<string|int, mixed> —data returned by the name server.
finishTasks()
This method is called on the name server to finish processing any data returned by MediaUpdater clients.
public
finishTasks() : mixed
Return values
mixed —generateThumbs()
Used to generate in $thumb_folder all the missing thumbnails for resources in $folder
public
generateThumbs(string $folder, string $thumb_folder) : mixed
Parameters
- $folder : string
-
name of a Yioop wiki resource folder
- $thumb_folder : string
-
name of thumbnail folder associated with Yioop wiki resource folder.
Return values
mixed —getCurrentMachine()
Returns a hash of the url of the current machine based on the value saved to self::current_machine_info_file by a machine statuses request
public
static getCurrentMachine() : string
Return values
string —hash of current machine url
getJobName()
Gets the class name (less namespace and the word Job ) of the current MediaJob
public
static getJobName() : string
Return values
string —name of the current job
getTasks()
Method called from JobController when a MediaUpdater client contacts the name server's web app. This method is supposed to marshal any data on the name server that the requesting client should process.
public
getTasks(int $machine_id[, array<string|int, mixed> $data = null ]) : array<string|int, mixed>
Parameters
- $machine_id : int
-
id of client requesting data
- $data : array<string|int, mixed> = null
-
any additional info about data being requested
Return values
array<string|int, mixed> —work for the client to process
init()
Initializes the last update time to far in the past so, missing thumb folders will get processed immediately when MediaUpdater first run.
public
init() : mixed
immediately updated. Sets up a GroupModel object so can use its method for genrasting thumbs.
Return values
mixed —nondistributedTasks()
Gets all folder files describing Wiki pages with resources that need thumbs. Then creates thumbs for them. Since the wiki is only on the name server all tasks will be nondistributedTasks.
public
nondistributedTasks() : mixed
Return values
mixed —prepareTasks()
This method is called on the name server to prepare data for any MediaUpdater clients.
public
prepareTasks() : mixed
Return values
mixed —putTasks()
After a MediaUpdater client is done with the task given to it by the name server's media updater, the client contact the name server's web app. The name servers web app's JobController then calls this method to receive the data on the name server
public
putTasks(int $machine_id, mixed $data) : array<string|int, mixed>
Parameters
- $machine_id : int
-
id of client that is sending data to name server
- $data : mixed
-
results of computation done by client
Return values
array<string|int, mixed> —any response information to send back to the client
run()
Method executed by MediaUpdater to perform the MediaJob. This method shouldn't need to be overridden. Instead, the various callbacks it calls (listed in the class description) wshould be overridden.
public
run() : mixed