本文整理汇总了PHP中Mapper::join方法的典型用法代码示例。如果您正苦于以下问题:PHP Mapper::join方法的具体用法?PHP Mapper::join怎么用?PHP Mapper::join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mapper
的用法示例。
在下文中一共展示了Mapper::join方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHTML
/**
* Get HTML representation of the given object.
* @param Feed $object object to be converted to HMTL.
* @return string HTML representation of the object
*/
public static function getHTML($object, $shine = '')
{
// Format username
$username = FeedV::_getUsername($object->user_id);
$username_displayed = ucwords($username);
$feed_meta_simple = '';
// Format simple meta feed
$feedMetaSimpleMapper = new Mapper('Feed');
$feedMetaSimpleMapper->ljoin('Meta', 'meta.target_id = feed.id')->filter('meta.target_type=(?)', 'feed')->filter('meta.name=(?)', 'sharer_id')->filter('meta.target_id=(?)', $object->id)->filter('meta.type=(?)', 'simple');
$feedMetaSimpleResults = $feedMetaSimpleMapper->get();
$shared_feed = false;
if (count($feedMetaSimpleResults['Meta']) >= 1) {
$username_displayed = 'Shared by ' . ucwords(FeedV::_getUsername($feedMetaSimpleResults['Meta'][0]->value));
$shared_feed = true;
}
// Format advanced meta feed
$root_id = 0;
$root_id = FeedV::findFirstRootID($object->id);
$feed_meta_advanced = $feed_meta_simple;
$feed_status = 'feed_success';
$feed_folder = joinPaths(CHRIS_USERS, $username, $object->plugin, $object->name . '-' . $object->id);
if ($handle = opendir($feed_folder)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
$match = glob($feed_folder . '/' . $entry . '/_chrisRun_/ERR*');
if (count($match)) {
$feed_status = 'feed_failure';
break;
}
if ($feed_status == 'feed_failure') {
break;
}
}
}
}
// create the status text
$status_text = '<span style="background-color: #009DE9;color: #fff;padding: 1px 2px;">Running<i class="icon-refresh rotating_class"></i></span>';
// ('.$object->status.'%)
if ($feed_status == 'feed_failure') {
$status_text = '<span style="background-color: #E90000;color: #fff;padding: 1px 2px;">Errors</span>';
$feed_status = 'feed_success';
} else {
if ($object->status == 100) {
$status_text = '<span style="background-color: #41E900;color: #fff;padding: 1px 2px;">Success</span>';
} else {
if ($object->status == 101) {
$status_text = '<span style="background-color: #E95D00;color: #fff;padding: 1px 2px;">Canceled</span>';
}
}
}
$view_icon = 'icon-eye-open';
$share_icon = 'icon-share-alt';
$tag_icon = 'icon-tag';
$archive_icon = 'icon-remove';
$archive_text = 'Archive';
if ($object->archive == '1') {
$archive_icon = 'icon-plus';
$archive_text = 'Restore';
}
$favorite_icon = 'icon-star-empty';
$favorite_text = 'Favorite';
if ($object->favorite == '1') {
$favorite_icon = 'icon-star';
$favorite_text = '<b>Favorited</b>';
}
$edit_icon = '';
$cancel = '';
$view = "display:none";
if ($object->status >= 100 || $shared_feed) {
$edit_icon = "<img class='feed_edit_icon show_me focus' src='view/gfx/jigsoar-icons/dark/16_edit_page2.png'>";
// if the job is not queued or running, don't display the cancel icon
// also if the feed was shared
$cancel = "display:none";
$view = "";
}
$t = new Template('feed.html');
$t->replace('ID', $object->id);
$t->replace('ROOT_ID', $root_id);
$feed_gfx64 = 'plugins/' . $object->plugin . '/feed.png';
$feed_gfx64_checked = 'view/gfx/feed_checked.png';
if (!is_file(joinPaths(CHRIS_WWWROOT, $feed_gfx64))) {
$feed_gfx64 = 'http://placehold.it/48x48';
}
$t->replace('IMAGE_SRC', $feed_gfx64);
$t->replace('IMAGE_CHECKED', $feed_gfx64_checked);
$t->replace('USERNAME', $username_displayed);
$t->replace('FEED_STATUS', $feed_status);
$t->replace('FEED_NAME', $object->name);
$t->replace('FEED_META_CONTENT', $feed_meta_advanced);
$t->replace('TIME_FORMATED', $object->time);
$t->replace('PLUGIN', ucwords(str_replace('_', ' ', $object->plugin)));
$t->replace('STATUS', $object->status);
$t->replace('STATUS_TEXT', $status_text);
$t->replace('VIEW_ICON', $view_icon);
$t->replace('SHARE_ICON', $share_icon);
//.........这里部分代码省略.........
示例2: status
public static function status($feedid, $status, $op)
{
// get $db instance
$db = DB::getInstance();
$db->lock('feed', 'WRITE');
// grab the feed
$feedResult = Mapper::getStatic('Feed', $feedid);
if (count($feedResult['Feed']) == 0) {
$db->unlock();
die('Invalid feed id.');
}
# grab old status
$old_status = $feedResult['Feed'][0]->status;
$type = gettype($status);
echo "Performing '{$op}' with value '{$status}' on current status '{$old_status}'\n";
if ($op == 'inc') {
// increasing mode
echo "Increasing status of feed {$feedid} by {$status}... ";
# increase status
$status = $old_status + $status;
}
if ($op == 'set') {
// set mode
if ($old_status >= $status || $status > 100) {
$db->unlock();
die("Ignoring setting the status since the old status {$old_status} >= the new status {$status} or the old status >= 100.\n");
} else {
echo "Setting status of feed {$feedid} to {$status}... ";
}
}
echo "status now {$status}.\n";
# clamp the addition
if ($status >= 100) {
$status = 100;
$startTime = $feedResult['Feed'][0]->time;
$endTime = microtime(true);
$duration = $endTime - $startTime;
$feedResult['Feed'][0]->time = $endTime;
$feedResult['Feed'][0]->duration = $duration;
}
# push to database
$feedResult['Feed'][0]->status = $status;
Mapper::update($feedResult['Feed'][0], $feedid);
$db->unlock();
# update related shared feeds
$relatedMapper = new Mapper('Feed');
$relatedMapper->join('Meta', 'Meta.target_id = Feed.id')->filter('Meta.name = (?)', 'root_id')->filter('Meta.value = (?)', $feedResult['Feed'][0]->id)->filter('Feed.id != (?)', $feedResult['Feed'][0]->id);
$relatedResult = $relatedMapper->get();
foreach ($relatedResult['Feed'] as $key => $value) {
$relatedResult['Feed'][$key]->time = $feedResult['Feed'][0]->time;
$relatedResult['Feed'][$key]->duration = $feedResult['Feed'][0]->duration;
$relatedResult['Feed'][$key]->status = $feedResult['Feed'][0]->status;
Mapper::update($relatedResult['Feed'][$key], $relatedResult['Feed'][$key]->id);
}
# send email if status == 100
if ($status == 100) {
// user's email
$userMapper = new Mapper('User');
$userMapper->filter('user.id = (?)', $feedResult['Feed'][0]->user_id);
$userResult = $userMapper->get();
// if nothing in DB yet, return -1
if (count($userResult['User']) > 0) {
$subject = "ChRIS2 - " . $feedResult['Feed'][0]->plugin . " plugin finished";
$message = "Hello " . $userResult['User'][0]->username . "," . PHP_EOL . PHP_EOL;
$message .= "Your results are available at:" . PHP_EOL . PHP_EOL;
$dirRoot = joinPaths(CHRIS_USERS, $userResult['User'][0]->username, $feedResult['Feed'][0]->plugin, $feedResult['Feed'][0]->name . '-' . $feedResult['Feed'][0]->id);
$dataDir = array_diff(scandir($dirRoot), array('..', '.'));
foreach ($dataDir as $dir) {
$mailFilePath = $dirRoot . '/' . $dir . '/_chrisRun_/' . 'chris.mail';
if (file_exists($mailFilePath)) {
$mailContents = file_get_contents($mailFilePath);
$message .= $dirRoot . '/' . $dir . PHP_EOL . $mailContents . PHP_EOL . PHP_EOL;
} else {
$message .= $dirRoot . '/' . $dir . PHP_EOL . PHP_EOL;
}
}
$message .= "Thank you for using ChRIS.";
echo "Sending email to " . $userResult['User'][0]->email . " since the status is '{$status}'%.\n";
// get user email address
email(CHRIS_PLUGIN_EMAIL_FROM, $userResult['User'][0]->email, $subject, $message);
}
}
}