本文整理汇总了PHP中aTools::getCurrentPage方法的典型用法代码示例。如果您正苦于以下问题:PHP aTools::getCurrentPage方法的具体用法?PHP aTools::getCurrentPage怎么用?PHP aTools::getCurrentPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aTools
的用法示例。
在下文中一共展示了aTools::getCurrentPage方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup
protected function setup()
{
if (!isset($this->options)) {
// Prevents numerous warnings and problems if there are no slot options present
$this->options = array();
}
$this->page = aTools::getCurrentPage();
$this->slug = $this->page->slug;
// TODO: remove this workaround in 1.5. All uses of actual_slug and real-slug need to go away
// in favor of actual_url, we just don't want to break any old overrides in client projects.
$this->realSlug = aTools::getRealPage() ? aTools::getRealPage()->getSlug() : 'global';
$this->slot = $this->page->getSlot($this->name, $this->permid);
if (!$this->slot || $this->slot->type !== $this->type) {
$this->slot = $this->page->createSlot($this->type);
}
if ($this->getOption('edit')) {
$this->editable = true;
} else {
if (aTools::getAllowSlotEditing()) {
$this->editable = $this->page->userHasPrivilege('edit');
} else {
$this->editable = false;
}
}
if ($this->getOption('preview')) {
$this->editable = false;
}
if ($this->editable) {
$user = $this->getUser();
$id = $this->page->getId();
$name = $this->name;
$permid = $this->permid;
// Make sure the options passed to a_slot
// can be found again at save time
if (!$this->updating) {
// Slot options can be influenced by variant switching, and that's fine, and the editor might
// need to know about it to do the right thing, so it's appropriate to reset the slot
// options in the attribute. However, we also need to know what the original, pristine
// options from a_slot or a_area were in order to allow variants to be switched without
// having side effects on each other's option sets
$user->setAttribute("slot-original-options-{$id}-{$name}-{$permid}", $this->options, 'apostrophe');
// Refactored to get rid of duplicate logic
$allowedVariants = array_keys(aTools::getVariantsForSlotType($this->type, $this->options));
$user->setAttribute("slot-allowed-variants-{$id}-{$name}-{$permid}", $allowedVariants, 'apostrophe');
}
$user->setAttribute("slot-options-{$id}-{$name}-{$permid}", $this->options, 'apostrophe');
}
// Calling getEffectiveVariant ensures we default to the behavior of the first one
// defined, or the first one allowed if there is an allowed_variants option
$variant = $this->slot->getEffectiveVariant($this->options);
if ($variant) {
// Allow slot variants to adjust slot options. This shouldn't be used to radically
// change the slot, just as an adjunct to CSS, styling things in ways CSS can't
$variants = aTools::getVariantsForSlotType($this->slot->type, $this->options);
if (isset($variants[$variant]['options'])) {
$options = $variants[$variant]['options'];
$this->options = array_merge($this->options, $options);
}
}
$this->pageid = $this->page->id;
$this->id = $this->pageid . '-' . $this->name . '-' . $this->permid;
// The basic slot types, and some custom slot types, are
// simplified by having this field ready to go
$this->value = $this->slot->value;
// Not everyone wants the default 'double click the outline to
// start editing' behavior
$this->outlineEditable = $this->editable && $this->getOption('outline_editable', $this->slot->isOutlineEditable());
// Useful if you're reimplementing that via a button etc
$id = $this->id;
$this->showEditorJS = "\$('#content-{$id}').hide(); \$('#form-{$id}').fadeIn();";
if (isset($this->validationData['form'])) {
// Make Symfony 1.2 form validation extra-convenient
$this->form = $this->validationData['form'];
}
}
示例2: a_navaccordion
function a_navaccordion()
{
$page = aTools::getCurrentPage();
$children = $page->getAccordionInfo(true);
return a_navtree_body($children);
}
示例3: use_helper
<?php
use_helper('jQuery', 'Url', 'I18N');
?>
<?php
$page = aTools::getCurrentPage();
?>
<?php
if ($edit) {
?>
<form method="POST" action="<?php
echo url_for('a/rename') . '?' . http_build_query(array('id' => $page->id));
?>
" id="a-breadcrumb-rename-form" class="epc-form a-breadcrumb-form rename">
<?php
$form = new aRenameForm($page);
?>
<?php
echo $form->renderHiddenFields();
?>
<?php
echo $form['title']->render(array('id' => 'a-breadcrumb-rename-title'));
?>
<ul id="a-breadcrumb-rename-controls" class="a-form-controls a-breadcrumb-controls rename" style="display:none;">
<li>
示例4: a_navcolumn
function a_navcolumn()
{
$page = aTools::getCurrentPage();
return _a_navcolumn_body($page);
}
示例5: executeIndex
public function executeIndex(sfRequest $request)
{
$params = array();
$tag = $request->getParameter('tag');
$type = $request->getParameter('type');
$category = $request->getParameter('category');
if (aMediaTools::getType()) {
$type = aMediaTools::getType();
}
$search = $request->getParameter('search');
if ($request->isMethod('post')) {
// Give the routing engine a shot at making the URL pretty.
// We use addParams because it automatically deletes any
// params with empty values. (To be fair, http_build_query can't
// do that because some crappy web application might actually
// use checkboxes with empty values, and that's not
// technically wrong. We have the luxury of saying "reasonable
// people who work here don't do that.")
return $this->redirect(aUrl::addParams("aMedia/index", array("tag" => $tag, "search" => $search, "type" => $type)));
}
if (!empty($tag)) {
$params['tag'] = $tag;
}
if (!empty($search)) {
$params['search'] = $search;
}
if (!empty($type)) {
$params['type'] = $type;
}
if (!empty($category)) {
$params['category'] = $category;
}
$user = $this->getUser();
if ($user->isAuthenticated() && method_exists($user, "getGuardUser")) {
$params['user'] = $user->getGuardUser()->getUsername();
}
// Cheap insurance that these are integers
$aspectWidth = floor(aMediaTools::getAttribute('aspect-width'));
$aspectHeight = floor(aMediaTools::getAttribute('aspect-height'));
// TODO: performance of these is not awesome (it's a linear search).
// It would be more awesome with the right kind of indexing. For the
// aspect ratio test to be more efficient we'd have to store the lowest
// common denominator aspect ratio and index that.
if ($aspectWidth && $aspectHeight) {
$params['aspect-width'] = $aspectWidth;
$params['aspect-height'] = $aspectHeight;
}
$minimumWidth = floor(aMediaTools::getAttribute('minimum-width'));
if ($minimumWidth) {
$params['minimum-width'] = $minimumWidth;
}
$minimumHeight = floor(aMediaTools::getAttribute('minimum-height'));
if ($minimumHeight) {
$params['minimum-height'] = $minimumHeight;
}
$width = floor(aMediaTools::getAttribute('width'));
if ($width) {
$params['width'] = $width;
}
$height = floor(aMediaTools::getAttribute('height'));
if ($height) {
$params['height'] = $height;
}
// The media module is now an engine module. There is always a page, and that
// page might have a restricted set of categories associated with it
$mediaCategories = aTools::getCurrentPage()->MediaCategories;
if (count($mediaCategories)) {
$params['allowed_categories'] = $mediaCategories;
}
$query = aMediaItemTable::getBrowseQuery($params);
$this->pager = new sfDoctrinePager('aMediaItem', aMediaTools::getOption('per_page'));
$this->pager->setQuery($query);
$page = $request->getParameter('page', 1);
$this->pager->setPage($page);
$this->pager->init();
$this->results = $this->pager->getResults();
aMediaTools::setSearchParameters(array("tag" => $tag, "type" => $type, "search" => $search, "page" => $page, 'category' => $category));
$this->pagerUrl = "aMedia/index?" . http_build_query($params);
if (aMediaTools::isSelecting()) {
$this->selecting = true;
if (aMediaTools::getAttribute("label")) {
$this->label = aMediaTools::getAttribute("label");
}
$this->limitSizes = false;
if ($aspectWidth || $aspectHeight || $minimumWidth || $minimumHeight || $width || $height) {
$this->limitSizes = true;
}
}
}
示例6: getChildren
public function getChildren($livingOnly = true, $withSlot = 'title')
{
if ($this->childrenCache !== null) {
if ($livingOnly === $this->childrenCacheLivingOnly && $this->childrenCacheSlot === $withSlot) {
return $this->childrenCache;
}
}
// TODO: consider whether it's possible to get the base query to
// exclude archived children. That would result in multiple
// calls to where(), but perhaps Doctrine can combine them for us.
if ($withSlot !== false) {
aPageTable::treeSlotOn($withSlot);
}
$children = $this->getNode()->getChildren();
if ($children === false) {
$children = array();
}
if ($withSlot !== false) {
aPageTable::treeSlotOff();
}
// Don't let Doctrine's clever reuse of objects prevent us from seeing
// the results if we fetch a different slot this time... unless the child
// is also the current page. In that case we assume that we have superior
// data in the cache already (inclusive of all slots). Discarding that
// was leading to disappearing data on emap
$current = aTools::getCurrentPage();
foreach ($children as $child) {
if ($current && $current->id === $child->id) {
continue;
}
$child->clearSlotCache();
}
if ($children !== false) {
$living = array();
$dead = array();
foreach ($children as $child) {
if ($child->admin) {
// Never show admin pages in navigation
continue;
}
if ($child->archived) {
$dead[] = $child;
} else {
$living[] = $child;
}
}
if ($livingOnly) {
$children = $living;
} else {
$children = array_merge($living, $dead);
}
} else {
$children = array();
}
$this->childrenCache = $children;
$this->childrenCacheLivingOnly = $livingOnly;
$this->childrenCacheSlot = $withSlot;
return $children;
}
示例7: include_component
if ($page && !$page->admin && $cmsAdmin && $pageEdit) {
?>
<div class="a-global-toolbar-this-page" id="a-global-toolbar-this-page">
<?php
include_component('a', 'breadcrumb');
?>
<div id="a-page-settings"></div>
</div>
<?php
}
?>
</div>
<?php
if (aTools::getCurrentPage()) {
?>
<?php
include_partial('a/historyBrowser', array('page' => $page));
}
?>
<div class="a-page-overlay"></div>
<script type="text/javascript">
$(document).ready(function() {
var thisPageStatus = 0;
var thisPage = $('#a-this-page-toggle')
$('#a-global-toolbar-this-page').hide();
thisPage.click(function(){
示例8: addPageToUrl
/**
* Prepends the current CMS page to the URL.
*
* @param string $url The URL so far obtained from parent::generate
* @param Boolean $absolute Whether to generate an absolute URL
*
* @return string The generated URL
*/
public static function addPageToUrl(sfRoute $route, $url, $absolute)
{
$defaults = $route->getDefaults();
$currentPage = aTools::getCurrentPage();
$engine = $defaults['module'];
if (isset(self::$targetEnginePages[$engine]) && count(self::$targetEnginePages[$engine])) {
$page = end(self::$targetEnginePages[$engine]);
} elseif (!$currentPage || $currentPage->engine !== $defaults['module']) {
$page = aPageTable::getFirstEnginePage($defaults['module']);
} else {
$page = $currentPage;
}
if (!$page) {
throw new sfException('Attempt to generate aRoute URL for module ' . $defaults['module'] . ' with no matching engine page on the site');
}
// A route URL of / for an engine route maps to the page itself, without a trailing /
if ($url === '/') {
$url = '';
}
// Ditto for / followed by a query string (missed this before)
if (substr($url, 0, 2) === '/?') {
$url = substr($url, 1);
}
$pageUrl = $page->getUrl($absolute);
// Strip controller off so it doesn't duplicate the controller in the
// URL we just generated. We could use the slug directly, but that would
// break if the CMS were not mounted at the root on a particular site.
// Take care to function properly in the presence of an absolute URL
if (preg_match("/^(https?:\\/\\/[^\\/]+)?\\/[^\\/]+\\.php(.*)\$/", $pageUrl, $matches)) {
$pageUrl = $matches[2];
}
return $pageUrl . $url;
}
示例9: executeNavigation
public function executeNavigation(sfRequest $request)
{
// What page are we starting from?
// Navigation on non-CMS pages is relative to the home page
if (!($this->page = aTools::getCurrentPage())) {
$this->page = aPageTable::retrieveBySlug('/');
}
if (!($this->activePage = aPageTable::retrieveBySlug($this->activeSlug))) {
$this->activePage = $this->page;
}
if (!($this->rootPage = aPageTable::retrieveBySlug($this->rootSlug))) {
$this->rootPage = $this->activePage;
}
// We build different page trees depending on the navigation type that was requested
if (!$this->type) {
$this->type = 'tree';
}
$class = 'aNavigation' . ucfirst($this->type);
if (!class_exists($class)) {
throw new sfException(sprintf('Navigation type "%s" does not exist.', $class));
}
$this->navigation = new $class($this->rootPage, $this->activePage, $this->options);
$this->draggable = $this->page->userHasPrivilege('edit');
// Users can pass class names to the navigation <ul>
$this->classes = '';
if (isset($this->options['classes'])) {
$this->classes .= $this->options['classes'];
}
$this->nest = 0;
// The type of the navigation also is used for styling
$this->classes .= ' ' . $this->type;
$this->navigation = $this->navigation->getItems();
if (count($this->navigation) == 0) {
return sfView::NONE;
}
}
示例10: getContextEngineSlug
/**
* If an engine page has already been pushed or we are on an engine page now,
* returns that engine page slug. Otherwise returns null. Useful to determine
* whether you should get clever or not in a getEngineSlug() method for an
* aDoctrineRoute.
*
* @param sfRoute $route
*
* @return string The engine slug, or null
*/
public static function getContextEngineSlug(sfRoute $route)
{
$defaults = $route->getDefaults();
$currentPage = aTools::getCurrentPage();
$engine = $defaults['module'];
if (isset(self::$targetEnginePageSlugs[$engine]) && count(self::$targetEnginePageSlugs[$engine])) {
return end(self::$targetEnginePageSlugs[$engine]);
} elseif ($currentPage && $currentPage->engine === $defaults['module']) {
return $currentPage->slug;
} else {
return null;
}
}
示例11: use_helper
<?php
use_helper('I18N');
$page = aTools::getCurrentPage();
if ($page) {
?>
<?php
if ($sf_user->getAttribute("show-archived", false, "apostrophe")) {
?>
<?php
echo link_to(__("Hide \"Off\" Pages", null, 'apostrophe'), "a/showArchived?state=0&id=" . aTools::getCurrentPage()->getId());
?>
<?php
} else {
?>
<?php
echo link_to(__("Show \"Off\" Pages", null, 'apostrophe'), "a/showArchived?state=1&id=" . aTools::getCurrentPage()->getId());
?>
<?php
}
}
示例12: globalToolsPrivilege
/**
* DOCUMENT ME
* @return mixed
*/
public static function globalToolsPrivilege()
{
// if you can edit the page, there are tools for you in the apostrophe
if (aTools::getCurrentPage() && aTools::getCurrentPage()->userHasPrivilege('edit')) {
return true;
}
// if you are the site admin, there are ALWAYS tools for you in the apostrophe
$user = sfContext::getInstance()->getUser();
return $user->hasCredential('cms_admin');
}
示例13: executeIndex
/**
* DOCUMENT ME
* @param sfWebRequest $request
* @return mixed
*/
public function executeIndex(sfWebRequest $request)
{
$params = array();
$tag = $request->getParameter('tag');
$type = aMediaTools::getType();
$type = $type ? $type : $request->getParameter('type');
// It is permissible to filter more narrowly if the overall type is a metatype (_downloadable)
if (substr($type, 0, 1) === '_') {
if ($request->getParameter('type')) {
$type = $request->getParameter('type');
}
}
$this->embedAllowed = aMediaTools::getEmbedAllowed();
$this->uploadAllowed = aMediaTools::getUploadAllowed();
$category = $request->getParameter('category');
$search = $request->getParameter('search');
if ($request->isMethod('post')) {
// Give the routing engine a shot at making the URL pretty.
// We use addParams because it automatically deletes any
// params with empty values. (To be fair, http_build_query can't
// do that because some crappy web application might actually
// use checkboxes with empty values, and that's not
// technically wrong. We have the luxury of saying "reasonable
// people who work here don't do that.")
return $this->redirect(aUrl::addParams("aMedia/index", array("tag" => $tag, "search" => $search, "type" => $type)));
}
if (!empty($tag)) {
$params['tag'] = $tag;
}
if (!empty($search)) {
$params['search'] = $search;
}
if (!empty($type)) {
$params['type'] = $type;
}
if (!empty($category)) {
$params['category'] = $category;
}
// Cheap insurance that these are integers
$aspectWidth = floor(aMediaTools::getAttribute('aspect-width'));
$aspectHeight = floor(aMediaTools::getAttribute('aspect-height'));
if ($type === 'image') {
// Now that we provide cropping tools, width and height should only exclude images
// that are too small to ever be cropped to that size
$minimumWidth = floor(aMediaTools::getAttribute('minimum-width'));
$width = floor(aMediaTools::getAttribute('width'));
$minimumWidth = max($minimumWidth, $width);
$minimumHeight = floor(aMediaTools::getAttribute('minimum-height'));
$height = floor(aMediaTools::getAttribute('height'));
$minimumHeight = max($minimumHeight, $height);
// Careful, aspect ratio can impose a bound on the other dimension
if ($minimumWidth && $aspectWidth) {
$minimumHeight = max($minimumHeight, $minimumWidth * $aspectHeight / $aspectWidth);
}
if ($minimumHeight && $aspectHeight) {
$minimumWidth = max($minimumWidth, $minimumHeight * $aspectWidth / $aspectHeight);
}
// We've updated these with implicit constraints from the aspect ratio, the width and height params, etc.
aMediaTools::setAttribute('minimum-width', $minimumWidth);
aMediaTools::setAttribute('minimum-height', $minimumHeight);
$params['minimum-width'] = $minimumWidth;
$params['minimum-height'] = $minimumHeight;
} else {
// TODO: performance of these is not awesome (it's a linear search).
// It would be more awesome with the right kind of indexing. For the
// aspect ratio test to be more efficient we'd have to store the lowest
// common denominator aspect ratio and index that.
if ($aspectWidth && $aspectHeight) {
$params['aspect-width'] = $aspectWidth;
$params['aspect-height'] = $aspectHeight;
}
$minimumWidth = floor(aMediaTools::getAttribute('minimum-width'));
if ($minimumWidth) {
$params['minimum-width'] = $minimumWidth;
}
$minimumHeight = floor(aMediaTools::getAttribute('minimum-height'));
if ($minimumHeight) {
$params['minimum-height'] = $minimumHeight;
}
$width = floor(aMediaTools::getAttribute('width'));
if ($width) {
$params['width'] = $width;
}
$height = floor(aMediaTools::getAttribute('height'));
if ($height) {
$params['height'] = $height;
}
}
// The media module is now an engine module. There is always a page, and that
// page might have a restricted set of categories associated with it
$mediaCategories = aTools::getCurrentPage()->Categories;
if (count($mediaCategories)) {
$params['allowed_categories'] = $mediaCategories;
}
$query = aMediaItemTable::getBrowseQuery($params);
//.........这里部分代码省略.........