本文整理汇总了PHP中t2函数的典型用法代码示例。如果您正苦于以下问题:PHP t2函数的具体用法?PHP t2怎么用?PHP t2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了t2函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get
static function get($block_id, $theme)
{
$block = "";
switch ($block_id) {
case "random_image":
// The random_query approach is flawed and doesn't always return a
// result when there actually is one. Retry a *few* times.
// @todo Consider another fallback if further optimizations are necessary.
$image_count = module::get_var("image_block", "image_count");
$items = array();
for ($i = 0; $i < $image_count; $i++) {
$attempts = 0;
$item = null;
do {
$item = item::random_query()->where("type", "!=", "album")->find_all(1)->current();
} while (!$item && $attempts++ < 3);
if ($item) {
$items[] = $item;
}
}
if ($items) {
$block = new Block();
$block->css_id = "g-image-block";
$block->title = t2("Random image", "Random images", $image_count);
$block->content = new View("image_block_block.html");
$block->content->items = $items;
}
break;
}
return $block;
}
开发者ID:Joe7,项目名称:gallery3,代码行数:31,代码来源:image_block_block.php
示例2: delete
public function delete($ptID = false)
{
$pagetype = PageType::getByID($ptID);
if (!is_object($pagetype)) {
$this->error->add(t('Invalid page type object.'));
}
$cmp = new \Permissions($pagetype);
if (!$cmp->canDeletePageType()) {
$this->error->add(t('You do not have access to delete this page type.'));
}
$count = $pagetype->getPageTypeUsageCount();
if ($count > 0) {
$this->error->add(t2(
'This page type is in use on %d page.',
'This page type is in use on %d pages.', $count));
}
if (!$this->token->validate('delete_page_type')) {
$this->error->add(t($this->token->getErrorMessage()));
}
if (!$this->error->has()) {
$pagetype->delete();
$this->redirect('/dashboard/pages/types', 'page_type_deleted');
}
$this->view();
}
开发者ID:robertdamoc,项目名称:concrete5,代码行数:27,代码来源:types.php
示例3: rescan
public function rescan() {
$files = $this->getRequestFiles('canEditFileContents');
$r = new FileEditResponse();
$r->setFiles($files);
$successMessage = '';
$errorMessage = '';
$successCount = 0;
foreach($files as $f) {
try {
$fv = $f->getApprovedVersion();
$resp = $fv->refreshAttributes();
switch ($resp) {
case \Concrete\Core\File\Importer::E_FILE_INVALID:
$errorMessage .= t('File %s could not be found.', $fv->getFilename()) . '<br/>';
break;
default:
$successCount++;
$successMessage = t2('%s file rescanned successfully.', '%s files rescanned successfully.',
$successCount);
break;
}
} catch(\Concrete\Flysystem\FileNotFoundException $e) {
$errorMessage .= t('File %s could not be found.', $fv->getFilename()) . '<br/>';
}
}
if ($errorMessage && !$successMessage) {
$e = new \Concrete\Core\Error\Error;
$e->add($errorMessage);
$r->setError($e);
} else {
$r->setMessage($errorMessage . $successMessage);
}
$r->outputJSON();
}
开发者ID:JeRoNZ,项目名称:concrete5-1,代码行数:35,代码来源:file.php
示例4: rescan_locale
public function rescan_locale()
{
if ($this->token->validate('rescan_locale')) {
$u = new \User();
if ($u->isSuperUser()) {
\Core::make('cache/request')->disable();
$section = Section::getByID($_REQUEST['locale']);
$target = new MultilingualProcessorTarget($section);
$processor = new Processor($target);
if ($_POST['process']) {
foreach ($processor->receive() as $task) {
$processor->execute($task);
}
$obj = new \stdClass();
$obj->totalItems = $processor->getTotalTasks();
echo json_encode($obj);
exit;
} else {
$processor->process();
}
$totalItems = $processor->getTotalTasks();
\View::element('progress_bar', array('totalItems' => $totalItems, 'totalItemsSummary' => t2("%d task", "%d tasks", $totalItems)));
exit;
}
}
}
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:26,代码来源:copy.php
示例5: update_index
static function update_index($task)
{
try {
$completed = $task->get("completed", 0);
$start = microtime(true);
foreach (ORM::factory("item")->join("exif_records", "items.id", "exif_records.item_id", "left")->where("type", "photo")->open_paren()->where("exif_records.item_id", null)->orwhere("exif_records.dirty", 1)->close_paren()->find_all() as $item) {
if (microtime(true) - $start > 1.5) {
break;
}
$completed++;
exif::extract($item);
}
list($remaining, $total, $percent) = exif::stats();
$task->set("completed", $completed);
if ($remaining == 0 || !($remaining + $completed)) {
$task->done = true;
$task->state = "success";
site_status::clear("exif_index_out_of_date");
$task->percent_complete = 100;
} else {
$task->percent_complete = round(100 * $completed / ($remaining + $completed));
}
$task->status = t2("one record updated, index is %percent% up-to-date", "%count records updated, index is %percent% up-to-date", $completed, array("percent" => $percent));
} catch (Exception $e) {
$task->done = true;
$task->state = "error";
$task->status = $e->getMessage();
$task->log($e->__toString());
}
}
开发者ID:shai,项目名称:gallery3,代码行数:30,代码来源:exif_task.php
示例6: fix_internet_addresses
static function fix_internet_addresses($task)
{
$start = microtime(true);
$total = $task->get("total");
if (empty($total)) {
$task->set("total", $total = db::build()->count_records("items"));
$task->set("last_id", 0);
$task->set("completed", 0);
}
$last_id = $task->get("last_id");
$completed = $task->get("completed");
foreach (ORM::factory("item")->where("id", ">", $last_id)->find_all(100) as $item) {
$item->slug = item::convert_filename_to_slug($item->slug);
$item->save();
$last_id = $item->id;
$completed++;
if ($completed == $total || microtime(true) - $start > 1.5) {
break;
}
}
$task->set("completed", $completed);
$task->set("last_id", $last_id);
if ($total == $completed) {
$task->done = true;
$task->state = "success";
$task->percent_complete = 100;
db::build()->update("items")->set("relative_path_cache", null)->set("relative_url_cache", null)->execute();
} else {
$task->percent_complete = round(100 * $completed / $total);
}
$task->status = t2("One row updated", "%count / %total rows updated", $completed, array("total" => $total));
}
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:32,代码来源:rescue_task.php
示例7: run
public function run()
{
Cache::disableCache();
Loader::library('database_indexed_search');
$is = new IndexedSearch();
if ($_GET['force'] == 1) {
Loader::model('attribute/categories/collection');
Loader::model('attribute/categories/file');
Loader::model('attribute/categories/user');
$attributes = CollectionAttributeKey::getList();
$attributes = array_merge($attributes, FileAttributeKey::getList());
$attributes = array_merge($attributes, UserAttributeKey::getList());
foreach ($attributes as $ak) {
$ak->updateSearchIndex();
}
$result = $is->reindexAll(true);
} else {
$result = $is->reindexAll();
}
if ($result->count == 0) {
return t('Indexing complete. Index is up to date');
} else {
if ($result->count == $is->searchBatchSize) {
return t('Index partially updated. %s pages indexed (maximum number.) Re-run this job to continue this process.', $result->count);
} else {
return t('Index updated.') . ' ' . t2('%d page required reindexing.', '%d pages required reindexing.', $result->count, $result->count);
}
}
}
开发者ID:Zyqsempai,项目名称:amanet,代码行数:29,代码来源:index_search.php
示例8: update_index
static function update_index($task)
{
try {
$completed = $task->get("completed", 0);
$start = microtime(true);
foreach (ORM::factory("item")->join("exif_records", "items.id", "exif_records.item_id", "left")->where("type", "=", "photo")->and_open()->where("exif_records.item_id", "IS", null)->or_where("exif_records.dirty", "=", 1)->close()->find_all() as $item) {
// The query above can take a long time, so start the timer after its done
// to give ourselves a little time to actually process rows.
if (!isset($start)) {
$start = microtime(true);
}
exif::extract($item);
$completed++;
if (microtime(true) - $start > 1.5) {
break;
}
}
list($remaining, $total, $percent) = exif::stats();
$task->set("completed", $completed);
if ($remaining == 0 || !($remaining + $completed)) {
$task->done = true;
$task->state = "success";
site_status::clear("exif_index_out_of_date");
$task->percent_complete = 100;
} else {
$task->percent_complete = round(100 * $completed / ($remaining + $completed));
}
$task->status = t2("one record updated, index is %percent% up-to-date", "%count records updated, index is %percent% up-to-date", $completed, array("percent" => $percent));
} catch (Exception $e) {
$task->done = true;
$task->state = "error";
$task->status = $e->getMessage();
$task->log((string) $e);
}
}
开发者ID:andyst,项目名称:gallery3,代码行数:35,代码来源:exif_task.php
示例9: rebuild_dirty_images
/**
* Task that rebuilds all dirty images.
* @param Task_Model the task
*/
static function rebuild_dirty_images($task)
{
$result = graphics::find_dirty_images_query();
$remaining = $result->count();
$completed = $task->get("completed", 0);
$i = 0;
foreach ($result as $row) {
$item = ORM::factory("item", $row->id);
if ($item->loaded) {
graphics::generate($item);
}
$completed++;
$remaining--;
if (++$i == 2) {
break;
}
}
$task->status = t2("Updated: 1 image. Total: %total_count.", "Updated: %count images. Total: %total_count.", $completed, array("total_count" => $remaining + $completed));
if ($completed + $remaining > 0) {
$task->percent_complete = (int) (100 * $completed / ($completed + $remaining));
} else {
$task->percent_complete = 100;
}
$task->set("completed", $completed);
if ($remaining == 0) {
$task->done = true;
$task->state = "success";
site_status::clear("graphics_dirty");
}
}
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:34,代码来源:core_task.php
示例10: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$db = \Database::connection();
$em = $db->getEntityManager();
$cacheDriver = $em->getConfiguration()->getMetadataCacheImpl();
$cacheDriver->flushAll();
$tool = new \Doctrine\ORM\Tools\SchemaTool($em);
$schemas = [];
/**
* @var $sm MySqlSchemaManager
*/
$sm = $db->getSchemaManager();
$dbSchema = $sm->createSchema();
// core xml tables
$schemas[] = Schema::getCoreXMLSchema();
// core entities
$sm = new DatabaseStructureManager($em);
$entities = $sm->getMetadatas();
$schemas[] = $tool->getSchemaFromMetadata($entities);
// core, application and package block types
$env = Environment::get();
$list = new BlockTypeList();
$list->includeInternalBlockTypes();
foreach ($list->get() as $bt) {
$r = $env->getRecord(DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . '/' . FILENAME_BLOCK_DB, $bt->getPackageHandle());
if ($r->exists()) {
$parser = Schema::getSchemaParser(simplexml_load_file($r->file));
$parser->setIgnoreExistingTables(false);
$schemas[] = $parser->parse($db);
}
}
// packages
$packages = Package::getInstalledList();
foreach ($packages as $pkg) {
$xmlFile = $pkg->getPackagePath() . '/' . FILENAME_BLOCK_DB;
if (file_exists($xmlFile)) {
$parser = Schema::getSchemaParser(simplexml_load_file($xmlFile));
$parser->setIgnoreExistingTables(false);
$schemas[] = $parser->parse($db);
}
}
// Finalize output.
$comparator = new \Doctrine\DBAL\Schema\Comparator();
$saveQueries = array();
foreach ($schemas as $schema) {
$schemaDiff = $comparator->compare($dbSchema, $schema);
$saveQueries = array_merge($saveQueries, $schemaDiff->toSaveSql($db->getDatabasePlatform()));
}
$saveQueries = $this->filterQueries($saveQueries);
if (count($saveQueries)) {
$output->writeln(t2('%s query found', '%s queries found', count($saveQueries)));
$i = 1;
foreach ($saveQueries as $query) {
$output->writeln(sprintf('%s: %s', $i, $query));
$i++;
}
} else {
$output->writeln(t('No differences found between schema and database.'));
}
}
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:60,代码来源:CompareSchemaCommand.php
示例11: run
public function run()
{
$cfg = new Config();
$pNum = (int) $cfg->get('OLD_VERSION_JOB_PAGE_NUM');
$pNum = $pNum < 0 ? 1 : $pNum + 1;
$pl = new PageList();
$pl->setItemsPerPage(3);
/* probably want to keep a record of pages that have been gone through
* so you don't start from the beginning each time..
*/
$pages = $pl->getPage($pNum);
if (!count($pages)) {
$cfg->save('OLD_VERSION_JOB_PAGE_NUM', 0);
return t("All pages have been processed, starting from beginning on next run.");
}
$versionCount = 0;
$pagesAffected = array();
foreach ($pages as $page) {
if ($page instanceof Page) {
$pvl = new VersionList($page);
$pagesAffected[] = $page->getCollectionID();
foreach (array_slice(array_reverse($pvl->getVersionListArray()), 10) as $v) {
if ($v instanceof CollectionVersion && !$v->isApproved() && !$v->isMostRecent()) {
@$v->delete();
$versionCount++;
}
}
}
}
$pageCount = count($pagesAffected);
$cfg->save('OLD_VERSION_JOB_PAGE_NUM', $pNum);
//i18n: %1$d is the number of versions deleted, %2$d is the number of affected pages, %3$d is the number of times that the Remove Old Page Versions job has been executed.
return t2('%1$d versions deleted from %2$d page (%3$d)', '%1$d versions deleted from %2$d pages (%3$s)', $pageCount, $versionCount, $pageCount, implode(',', $pagesAffected));
}
开发者ID:ronlobo,项目名称:concrete5,代码行数:34,代码来源:remove_old_page_versions.php
示例12: available_tasks
static function available_tasks()
{
$q = emboss::find_dirty();
$n = $q->count();
$description = $n == 0 ? t('All photo overlays are up to date') : t2('one Photo needs its emboss overlay updated', "{$n} Photos need their emboss overlay updated", $n);
$tasks[] = Task_Definition::factory()->callback('emboss_task::update_overlays')->name(t('Update photo embossing'))->description($description)->severity($n > 0 ? log::WARNING : log::SUCCESS);
return $tasks;
}
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:8,代码来源:emboss_task.php
示例13: clean_up_tags
/**
* Fix up tag counts and delete any tags that have no associated items.
* @param Task_Model the task
*/
static function clean_up_tags($task)
{
$errors = array();
try {
$start = microtime(true);
$last_tag_id = $task->get("last_tag_id", null);
$current = 0;
$total = 0;
switch ($task->get("mode", "init")) {
case "init":
$task->set("total", ORM::factory("tag")->count_all());
$task->set("mode", "clean_up_tags");
$task->set("completed", 0);
$task->set("last_tag_id", 0);
case "clean_up_tags":
$completed = $task->get("completed");
$total = $task->get("total");
$last_tag_id = $task->get("last_tag_id");
$tags = ORM::factory("tag")->where("id", ">", $last_tag_id)->find_all(25);
Kohana_Log::add("error", print_r(Database::instance()->last_query(), 1));
while ($current < $total && microtime(true) - $start < 1 && ($tag = $tags->current())) {
$last_tag_id = $tag->id;
$real_count = $tag->items_count();
if ($tag->count != $real_count) {
$tag->count = $real_count;
if ($tag->count) {
$task->log("Fixing count for tag {$tag->name} (id: {$tag->id}, new count: {$tag->count})");
$tag->save();
} else {
$task->log("Deleting empty tag {$tag->name} ({$tag->id})");
$tag->delete();
}
}
$completed++;
$tags->next();
}
$task->percent_complete = $completed / $total * 100;
$task->set("completed", $completed);
$task->set("last_tag_id", $last_tag_id);
}
$task->status = t2("Examined %count tag", "Examined %count tags", $completed);
if ($completed == $total) {
$task->done = true;
$task->state = "success";
$task->percent_complete = 100;
}
} catch (Exception $e) {
Kohana_Log::add("error", (string) $e);
$task->done = true;
$task->state = "error";
$task->status = $e->getMessage();
$errors[] = (string) $e;
}
if ($errors) {
$task->log($errors);
}
}
开发者ID:assad2012,项目名称:gallery3-appfog,代码行数:61,代码来源:tag_task.php
示例14: status
public function status($success_count, $error_count)
{
if ($error_count) {
// The "errors" won't be properly pluralized :-/
print t2("Uploaded %count photo (%error errors)", "Uploaded %count photos (%error errors)", (int) $success_count, array("error" => (int) $error_count));
} else {
print t2("Uploaded %count photo", "Uploaded %count photos", $success_count);
}
}
开发者ID:HarriLu,项目名称:gallery3,代码行数:9,代码来源:uploader.php
示例15: rescan_locale
public function rescan_locale()
{
if ($this->token->validate('rescan_locale')) {
$u = new \User();
if ($u->isSuperUser()) {
\Core::make('cache/request')->disable();
$section = Section::getByID($_REQUEST['locale']);
$target = new MultilingualProcessorTarget($section);
$processor = new Processor($target);
if ($_POST['process']) {
foreach ($processor->receive() as $task) {
$processor->execute($task);
}
$obj = new \stdClass();
$obj->totalItems = $processor->getTotalTasks();
print json_encode($obj);
exit;
} else {
$processor->process();
}
$totalItems = $processor->getTotalTasks();
\View::element('progress_bar', array('totalItems' => $totalItems, 'totalItemsSummary' => t2("%d task", "%d tasks", $totalItems)));
/*
$q = Queue::get('rescan_multilingual_section');
if ($_POST['process']) {
$obj = new \stdClass;
$messages = $q->receive(\Config::get('concrete.limits.copy_pages'));
foreach($messages as $key => $p) {
// delete the page here
$page = unserialize($p->body);
$oc = \Page::getByID($page['cID']);
$q->deleteMessage($p);
}
$obj->totalItems = $q->count();
print json_encode($obj);
if ($q->count() == 0) {
$q->deleteQueue('rescan_multilingual_section');
}
exit;
} else if ($q->count() == 0) {
$oc = Section::getByID($_REQUEST['locale']);
if (is_object($oc) && !$oc->isError()) {
$oc->queueForDeletionRequest($q, false);
}
}
$totalItems = $q->count();
\View::element('progress_bar', array('totalItems' => $totalItems, 'totalItemsSummary' => t2("%d page", "%d pages", $totalItems)));
*/
exit;
}
}
}
开发者ID:ceko,项目名称:concrete5-1,代码行数:56,代码来源:copy.php
示例16: _get_base_view
private function _get_base_view()
{
$view = new Admin_View("admin.html");
$view->content = new View("admin_comments.html");
$view->content->published = $this->_query(array("published"));
$view->content->unpublished = $this->_query(array("unpublished"));
$view->content->spam = $this->_query(array("spam"));
$view->content->deleted = $this->_query(array("deleted"));
$view->content->menu = Menu::factory("root")->append(Menu::factory("link")->id("unpublished")->label(t2("Awaiting Moderation (%count)", "Awaiting Moderation (%count)", $view->content->unpublished->count()))->url(url::site("admin/comments/queue/unpublished")))->append(Menu::factory("link")->id("published")->label(t2("Approved (%count)", "Approved (%count)", $view->content->published->count()))->url(url::site("admin/comments/queue/published")))->append(Menu::factory("link")->id("spam")->label(t2("Spam (%count)", "Spam (%count)", $view->content->spam->count()))->url(url::site("admin/comments/queue/spam")))->append(Menu::factory("link")->id("deleted")->label(t2("Recently Deleted (%count)", "Recently Deleted (%count)", $view->content->deleted->count()))->url(url::site("admin/comments/queue/deleted")));
return $view;
}
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:11,代码来源:admin_comments.php
示例17: run
public function run()
{
$pl = new PageList();
$pl->filterByCollectionTypeHandle('walk');
$pl->filterByName('', true);
$pages = $pl->get();
$pagecount = count($pages);
foreach ($pages as $page) {
$page->moveToTrash();
}
return $pagecount . ' ' . t2('page', 'pages', $pagecount) . ' moved to the trash';
}
开发者ID:r-bansal,项目名称:janeswalk-web-1,代码行数:12,代码来源:delete_abandoned_walks.php
示例18: index
/**
* Show a list of all available, running and finished tasks.
*/
public function index()
{
$query = db::build()->update("tasks")->set("state", "stalled")->where("done", "=", 0)->where("state", "<>", "stalled")->where(new Database_Expression("UNIX_TIMESTAMP(NOW()) - `updated` > 15"))->execute();
$stalled_count = $query->count();
if ($stalled_count) {
log::warning("tasks", t2("One task is stalled", "%count tasks are stalled", $stalled_count), t('<a href="%url">view</a>', array("url" => html::mark_clean(url::site("admin/maintenance")))));
}
$view = new Admin_View("admin.html");
$view->content = new View("admin_maintenance.html");
$view->content->task_definitions = task::get_definitions();
$view->content->running_tasks = ORM::factory("task")->where("done", "=", 0)->order_by("updated", "DESC")->find_all();
$view->content->finished_tasks = ORM::factory("task")->where("done", "=", 1)->order_by("updated", "DESC")->find_all();
print $view;
}
开发者ID:viosca,项目名称:gallery3,代码行数:17,代码来源:admin_maintenance.php
示例19: index
/**
* Show a list of all available, running and finished tasks.
*/
public function index()
{
$query = Database::instance()->query("UPDATE {tasks} SET `state` = 'stalled' " . "WHERE done = 0 " . "AND state <> 'stalled' " . "AND unix_timestamp(now()) - updated > 15");
$stalled_count = $query->count();
if ($stalled_count) {
log::warning("tasks", t2("One task is stalled", "%count tasks are stalled", $stalled_count), t('<a href="%url">view</a>', array("url" => html::mark_clean(url::site("admin/maintenance")))));
}
$view = new Admin_View("admin.html");
$view->content = new View("admin_maintenance.html");
$view->content->task_definitions = task::get_definitions();
$view->content->running_tasks = ORM::factory("task")->where("done", 0)->orderby("updated", "DESC")->find_all();
$view->content->finished_tasks = ORM::factory("task")->where("done", 1)->orderby("updated", "DESC")->find_all();
print $view;
}
开发者ID:Okat,项目名称:gallery3,代码行数:17,代码来源:admin_maintenance.php
示例20: index
/**
* Show a list of all available, running and finished tasks.
*/
public function index()
{
$query = Database::instance()->query("UPDATE `tasks` SET `state` = 'stalled' " . "WHERE done = 0 " . "AND state <> 'stalled' " . "AND unix_timestamp(now()) - updated > 120");
$stalled_count = $query->count();
if ($stalled_count) {
log::warning("tasks", t2("One task is stalled", "%count tasks are stalled", $stalled_count), t("%link_startview%link_end", array("link_start" => "<a href=\"" . url::site("admin/maintenance") . "\">", "link_start" => "</a>")));
}
$view = new Admin_View("admin.html");
$view->content = new View("admin_maintenance.html");
$view->content->task_definitions = $this->_get_task_definitions();
$view->content->running_tasks = ORM::factory("task")->where("done", 0)->orderby("updated", "desc")->find_all();
$view->content->finished_tasks = ORM::factory("task")->where("done", 1)->orderby("updated", "desc")->find_all();
$view->content->csrf = access::csrf_token();
print $view;
}
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:18,代码来源:admin_maintenance.php
注:本文中的t2函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论