Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Public Member Functions | List of all members
processAPACommand Class Reference

Public Member Functions

 actionIndex ($channel=false, $clear=false)
 actionSetup ()

Detailed Description

This command processes one channel with name $channel , and if $clear = 1 truncate tables before fill them

go to gportal/common: yiic processAPA –channel=test –clear=1

Install incron : 1)If Debian / Ubuntu Linux: sudo apt-get install incron

2)If RHEL / Fedora / CentOS Linux: sudo yum install incron

Start/Stop sudo /etc/init.d/incron stop sudo /etc/init.d/incron start

More info here: http://www.cyberciti.biz/faq/linux-inotify-examples-to-replicate-directories/

Author
Andrew Voloshin andre.nosp@m.w.vo.nosp@m.loshi.nosp@m.n@ob.nosp@m.erig..nosp@m.com

Definition at line 26 of file processAPACommand.php.

Member Function Documentation

processAPACommand::actionIndex (   $channel = false,
  $clear = false 
)

default action it processes channel with name $channel

Parameters
string$channelname of channel
int$clearwhether to truncate tables before import

Definition at line 35 of file processAPACommand.php.

References ApalinesNews\model().

{
Yii::app()->getModule('apalines');
if ($clear) {
if ($channel) {
$channels = array($channel);
} else {
$channels = Yii::app()->getModule('apalines')->channels;
$channels = array_keys($channels);
}
$notExistFolders = array();
foreach ($channels as $name) {
$ch = new Channel($name);
if (!file_exists($ch->path)) {
$notExistFolders[] = $name;
continue;
}
$news = ApalinesNews::model()->findAll('deleted <> 1');
foreach ($news as $line) {
$line->delete();
}
}
$channels = implode(', ', $channels);
echo "News of the channels: {$channels} are removed\n";
if (!empty($notExistFolders)) {
$notExistFolders = implode(', ', $notExistFolders);
echo "Channel folders of: {$notExistFolders} are not exist\n";
}
Yii::app()->end();
}
if (!$channel) {
echo "Channel name is not passed";
Yii::app()->end();
}
$channel = new Channel($channel);
if (!$channel->isNew()) {
echo "Fertig.txt does not exist in the channel folder\n";
Yii::app()->end();
}
$channel->clearOld();
$channel->moveToWork();
$channel->processWork();
}
processAPACommand::actionSetup ( )

action sets up incrontab to execute import command with current module settings

Definition at line 86 of file processAPACommand.php.

{
$incronPath = "/var/spool/incron/root";
$module = Yii::app()->getModule('apalines');
$channels = $module->channels;
$incronContent = '';
$yiicPath = Yii::getPathOfAlias('site.common').DIRECTORY_SEPARATOR."yiic";
$events = "IN_CREATE,IN_CLOSE_WRITE,IN_MOVED_TO";
foreach($channels as $alias => $channel){
$path = Yii::getPathOfAlias($channel['delivery_path']);
$command = "$yiicPath processApa index --channel=$alias";
$incronContent .= "$path $events $command\n";
}
file_put_contents($incronPath, $incronContent);
}

The documentation for this class was generated from the following file: