Example #1
0
 public function deleteAction()
 {
     $pageId = (int) $this->_getParam('id');
     $this->view->page = Page::getById($pageId);
     if (!$pageId or !$this->view->page) {
         $this->_flash('/admin/pages', 'Brak wpisu w bazie danych!!');
     }
     $this->view->form = $this->formPages('delete');
     $this->view->form->setAction('/admin/pages/delete/' . $pageId);
     $this->view->form->setDefaults((array) $this->view->page->_data);
     if (!$this->getRequest()->isPost() or !$_POST or !$this->view->form->isValid($_POST)) {
         return;
     }
     $error = false;
     try {
         $this->view->page->Menus->delete();
         $this->view->page->delete();
     } catch (Exception $e) {
         $error = true;
         $message = $e->getMessage();
     }
     if ($error) {
         $this->_flash('/admin/pages', $message);
     } else {
         $this->_flash('/admin/pages', 'Strona została usunięta z bazy danych!');
     }
 }
Example #2
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
$form = Loader::helper('form');
$searchWithinOther = $searchObj->baseSearchPath != $c->getCollectionPath() && $searchObj->baseSearchPath != '' && strlen($searchObj->baseSearchPath) > 0 ? true : false;
/**
 * Post to another page, get page object.
 */
$basePostPage = Null;
if (isset($searchObj->postTo_cID) && intval($searchObj->postTo_cID) > 0) {
    $basePostPage = Page::getById($searchObj->postTo_cID);
} else {
    if ($searchObj->pagePath != $c->getCollectionPath() && strlen($searchObj->pagePath)) {
        $basePostPage = Page::getByPath($searchObj->pagePath);
    }
}
/**
 * Verify object.
 */
if (is_object($basePostPage) && $basePostPage->isError()) {
    $basePostPage = NULL;
}
?>

<?php 
if (!$controller->indexExists()) {
    ?>
	<div class="ccm-error"><?php 
    echo t('The search index does not appear to exist. This block will not function until the reindex job has been run at least once in the dashboard.');
    ?>
<br/><br/></div>
Example #3
0
defined('C5_EXECUTE') or die("Access Denied.");
$aBlocks = $controller->generateNav();
$c = Page::getCurrentPage();
$containsPages = false;
$nh = Loader::helper('navigation');
//this will create an array of parent cIDs
$inspectC = $c;
$selectedPathCIDs = array($inspectC->getCollectionID());
$parentCIDnotZero = true;
while ($parentCIDnotZero) {
    $cParentID = $inspectC->cParentID;
    if (!intval($cParentID)) {
        $parentCIDnotZero = false;
    } else {
        $selectedPathCIDs[] = $cParentID;
        $inspectC = Page::getById($cParentID);
    }
}
foreach ($aBlocks as $ni) {
    $_c = $ni->getCollectionObject();
    if (!$_c->getCollectionAttributeValue('exclude_nav')) {
        $target = $ni->getTarget();
        if ($target != '') {
            $target = 'target="' . $target . '"';
        }
        if (!$containsPages) {
            // this is the first time we've entered the loop so we print out the UL tag
            echo "<ul class=\"nav\">";
        }
        $containsPages = true;
        $thisLevel = $ni->getLevel();
Example #4
0
 function view()
 {
     $c = Page::getCurrentPage();
     $this->set('title', $this->title);
     $this->set('buttonText', $this->buttonText);
     $this->set('baseSearchPath', $this->baseSearchPath);
     $this->set('postTo_cID', $this->postTo_cID);
     $resultsURL = $c->getCollectionPath();
     if ($this->resultsURL != '') {
         $resultsURL = $this->resultsURL;
     } else {
         if ($this->postTo_cID != '') {
             $resultsPage = Page::getById($this->postTo_cID);
             $resultsURL = $resultsPage->cPath;
         }
     }
     $this->set('resultTargetURL', $resultsURL);
     //run query if display results elsewhere not set, or the cID of this page is set
     if (!empty($_REQUEST['query']) || isset($_REQUEST['akID']) || isset($_REQUEST['month'])) {
         $this->do_search();
     }
 }
 if ($newCID > 0) {
     $dc = Page::getByID($newCID);
 } else {
     $dc = Page::getByID($page['destination']);
 }
 if ($_POST['multilingual']) {
     // Find multilingual section of the destination
     if (Section::isMultilingualSection($dc)) {
         $ms = Section::getByID($dc->getCollectionID());
     } else {
         $ms = Section::getBySectionOfSite($dc);
     }
     // Is page already copied?
     $existingCID = Section::getRelatedCollectionIDForLocale($page['cID'], $ms->getLocale());
     if ($existingCID) {
         $nc = Page::getById($existingCID);
         if ($dc->getCollectionID() != $nc->getCollectionParentID()) {
             $nc->move($dc);
         }
     } else {
         $nc = $oc->duplicate($dc);
     }
 } else {
     $nc = $oc->duplicate($dc);
 }
 $ocID = $oc->getCollectionID();
 $ncID = $nc->getCollectionID();
 if ($oc->getCollectionPointerOriginalID() > 0) {
     $ocID = $oc->getCollectionPointerOriginalID();
 }
 if ($nc->getCollectionPointerOriginalID() > 0) {
Example #6
0
 /**
  * New and improved version of "generateNav()" function.
  * Use this unless you need to maintain backwards compatibility with older custom templates.
  *
  * Pass in TRUE for the $ignore_exclude_nav arg if you don't want to exclude any pages
  *  (for both the "exclude_nav" and "exclude_subpages_from_nav" attribute).
  * This is useful for breadcrumb nav menus, for example.
  * 
  * Historical note: this must stay a function that gets called by the view templates
  * (as opposed to just having the view() method set the variables)
  * because we need to maintain the generateNav() function for backwards compatibility with
  * older custom templates... and that function unfortunately has side-effects so it cannot
  * be called more than once per request (otherwise there will be duplicate items in the nav menu).
  */
 public function getNavItems($ignore_exclude_nav = false)
 {
     $c = Page::getCurrentPage();
     //Create an array of parent cIDs so we can determine the "nav path" of the current page
     $inspectC = $c;
     $selectedPathCIDs = array($inspectC->getCollectionID());
     $parentCIDnotZero = true;
     while ($parentCIDnotZero) {
         $cParentID = $inspectC->cParentID;
         if (!intval($cParentID)) {
             $parentCIDnotZero = false;
         } else {
             if ($cParentID != HOME_CID) {
                 $selectedPathCIDs[] = $cParentID;
                 //Don't want home page in nav-path-selected
             }
             $inspectC = Page::getById($cParentID, 'ACTIVE');
         }
     }
     //Retrieve the raw "pre-processed" list of all nav items (before any custom attributes are considered)
     $allNavItems = $this->generateNav();
     //Remove excluded pages from the list (do this first because some of the data prep code needs to "look ahead" in the list)
     $includedNavItems = array();
     $excluded_parent_level = 9999;
     //Arbitrarily high number denotes that we're NOT currently excluding a parent (because all actual page levels will be lower than this)
     $exclude_children_below_level = 9999;
     //Same deal as above. Note that in this case "below" means a HIGHER number (because a lower number indicates higher placement in the sitemp -- e.g. 0 is top-level)
     foreach ($allNavItems as $ni) {
         $_c = $ni->getCollectionObject();
         $current_level = $ni->getLevel();
         if ($_c->getAttribute('exclude_nav') && $current_level <= $excluded_parent_level) {
             $excluded_parent_level = $current_level;
             $exclude_page = true;
         } else {
             if ($current_level > $excluded_parent_level || $current_level > $exclude_children_below_level) {
                 $exclude_page = true;
             } else {
                 $excluded_parent_level = 9999;
                 //Reset to arbitrarily high number to denote that we're no longer excluding a parent
                 $exclude_children_below_level = $_c->getAttribute('exclude_subpages_from_nav') ? $current_level : 9999;
                 $exclude_page = false;
             }
         }
         if (!$exclude_page || $ignore_exclude_nav) {
             $includedNavItems[] = $ni;
         }
     }
     //Prep all data and put it into a clean structure so markup output is as simple as possible
     $navItems = array();
     $navItemCount = count($includedNavItems);
     for ($i = 0; $i < $navItemCount; $i++) {
         $ni = $includedNavItems[$i];
         $_c = $ni->getCollectionObject();
         $current_level = $ni->getLevel();
         //Link target (e.g. open in new window)
         $target = $ni->getTarget();
         $target = empty($target) ? '_self' : $target;
         //Link URL
         $pageLink = false;
         if ($_c->getAttribute('replace_link_with_first_in_nav')) {
             $subPage = $_c->getFirstChild();
             //Note: could be a rare bug here if first child was excluded, but this is so unlikely (and can be solved by moving it in the sitemap) that it's not worth the trouble to check
             if ($subPage instanceof Page) {
                 $pageLink = Loader::helper('navigation')->getLinkToCollection($subPage);
                 //We could optimize by instantiating the navigation helper outside the loop, but this is such an infrequent attribute that I prefer code clarity over performance in this case
             }
         }
         if (!$pageLink) {
             $pageLink = $ni->getURL();
         }
         //Current/ancestor page
         $selected = false;
         $path_selected = false;
         if ($c->getCollectionID() == $_c->getCollectionID()) {
             $selected = true;
             //Current item is the page being viewed
             $path_selected = true;
         } elseif (in_array($_c->getCollectionID(), $selectedPathCIDs)) {
             $path_selected = true;
             //Current item is an ancestor of the page being viewed
         }
         //Calculate difference between this item's level and next item's level so we know how many closing tags to output in the markup
         $next_level = isset($includedNavItems[$i + 1]) ? $includedNavItems[$i + 1]->getLevel() : 0;
         $levels_between_this_and_next = $current_level - $next_level;
         //Determine if this item has children (can't rely on $ni->hasChildren() because it doesn't ignore excluded items!)
         $has_children = $next_level > $current_level;
         //Calculate if this is the first item in its level (useful for CSS classes)
         $prev_level = isset($includedNavItems[$i - 1]) ? $includedNavItems[$i - 1]->getLevel() : -1;
         $is_first_in_level = $current_level > $prev_level;
         //Calculate if this is the last item in its level (useful for CSS classes)
         $is_last_in_level = true;
         for ($j = $i + 1; $j < $navItemCount; $j++) {
             if ($includedNavItems[$j]->getLevel() == $current_level) {
                 //we found a subsequent item at this level (before this level "ended"), so this is NOT the last in its level
                 $is_last_in_level = false;
                 break;
             }
             if ($includedNavItems[$j]->getLevel() < $current_level) {
                 //we found a previous level before any other items in this level, so this IS the last in its level
                 $is_last_in_level = true;
                 break;
             }
         }
         //If loop ends before one of the "if" conditions is hit, then this is the last in its level (and $is_last_in_level stays true)
         //Custom CSS class
         $attribute_class = $_c->getAttribute('nav_item_class');
         $attribute_class = empty($attribute_class) ? '' : $attribute_class;
         //Page ID stuff
         $item_cid = $_c->getCollectionID();
         $is_home_page = $item_cid == HOME_CID;
         //Package up all the data
         $navItem = new stdClass();
         $navItem->url = $pageLink;
         $navItem->name = $ni->getName();
         $navItem->target = $target;
         $navItem->level = $current_level + 1;
         //make this 1-based instead of 0-based (more human-friendly)
         $navItem->subDepth = $levels_between_this_and_next;
         $navItem->hasSubmenu = $has_children;
         $navItem->isFirst = $is_first_in_level;
         $navItem->isLast = $is_last_in_level;
         $navItem->isCurrent = $selected;
         $navItem->inPath = $path_selected;
         $navItem->attrClass = $attribute_class;
         $navItem->isHome = $is_home_page;
         $navItem->cID = $item_cid;
         $navItem->cObj = $_c;
         $navItems[] = $navItem;
     }
     return $navItems;
 }
<?php

if (isset($_GET['code'])) {
    $pageIdToEdit = $database->escapeString($_GET['code']);
    $pageToEdit = new Page();
    $pageToEdit->setPageId($pageIdToEdit);
    $pageToEdit->getById($database);
}
?>
<div id="rightContainer"><!-- Open rightContainer -->
	<div id="addPageContainer">
		<form method="post" class="validateForm" id="" action="control/createPage.php">
			<table id="addTable">
				<thead>
					<tr>
						<th colspan="2">
							<span><?php 
if (isset($_GET['code'])) {
    echo "Edit page";
} else {
    echo "Add page";
}
?>
</span>
							<a href="#" id="properties" class="activeLinkInAdd">Properties</a>
							<a href="#" id="seo">SEO</a>
						</th>
					</tr>
				</thead>
				<tbody class="properties" style="display:table-header-group;">
					<tr>
Example #8
0
    if (count($results) == 0) {
        ?>
            	<h4 style="margin-bottom:30px"><?php 
        echo t('There were no results found. Please try another keyword or phrase.');
        ?>
</h4>
            <?php 
    } else {
        $tt = Core::make('helper/text');
        ?>
				<div class="searchSeparator"></div>
				<div class="searchList">
            	<?php 
        $ih = Loader::helper('image');
        foreach ($results as $r) {
            $oPage = Page::getById($r->getCollectionID());
            $oThumb = $oPage->getAttribute('thumbnail');
            ?>
                    <div class="searchSingle">
                    	<?php 
            if (isset($oThumb) && $oThumb != false) {
                ?>
                    	<div class="SearchImage">
                    		<a href="<?php 
                echo $r->getCollectionLink();
                ?>
">
                    			<?php 
                $image = $ih->getThumbnail($oThumb, 270, 200, true);
                ?>
									<img src="<?php 
    $cParentID = $inspectC->cParentID;
    if (!intval($cParentID)) {
        $parentCIDnotZero = false;
    } else {
        $selectedPathCIDs[] = $cParentID;
        $inspectC = Page::getById($cParentID);
    }
}
$pageTitle = "";
$parentID = $c->getCollectionParentID();
if ($displayPagesCID > 0) {
    $page = Page::getById($displayPagesCID);
    $pageTitle = $page->getCollectionName();
} else {
    if ($parentID > 1) {
        $page = Page::getById($parentID);
        $pageTitle = $page->getCollectionName();
    } else {
        $pageTitle = $c->getCollectionName();
    }
}
?>
<div class="mod corner aside">
	<div class="inner">
		<div class="hd local">
			<h3 class="h4"><?php 
echo $pageTitle;
?>
</h3>
		</div>
		<div class="bd">
Example #10
0
$links = new Links();
$pages = new Page();
$category = new Category();
if (isset($_POST['pageId']) && $_POST['pageId'] != "" && isset($_POST['menuId']) && $_POST['menuId'] != "" && isset($_POST['isCategory']) && $_POST['isCategory'] == "false") {
    // add pages to the menu
    $menuId = $database->escapeString($_POST['menuId']);
    $appearName = $database->escapeString($_POST['appearName']);
    $links->setMenuId($menuId);
    $links->setCategoryId(0);
    $links->setIsCustomLink(0);
    $links->setHttp("");
    $startPos = $links->numByMenu($database) + 1;
    foreach ($_POST['pageId'] as $id) {
        if ($appearName == "") {
            $pages->setPageId($id);
            $pages->getById($database);
            $links->setAppearName($pages->getPageName());
        } else {
            $links->setAppearName($appearName);
        }
        $links->setPosition($startPos);
        $links->setPageId($id);
        $links->create($database);
        $startPos++;
    }
    echo "true";
} else {
    if (isset($_POST['catIds']) && $_POST['catIds'] != "" && isset($_POST['menuId']) && $_POST['menuId'] != "" && isset($_POST['isCategory']) && $_POST['isCategory'] == "true") {
        // add pages to the menu
        $menuId = $database->escapeString($_POST['menuId']);
        $appearName = $database->escapeString($_POST['appearName']);