示例#1
0
<?php

$Pages = new PerchContent_Pages();
$Regions = new PerchContent_Regions();
$expand_list = array(0);
// Find new pages and initialise
$Pages->order_new_pages();
// Collapse list?
$do_list_collapse = $Settings->get('content_collapseList')->val();
$Perch->add_javascript_block("Perch.Apps.Content.settings = { 'collapseList':" . (PerchUtil::bool_val($do_list_collapse) ? 'true' : 'false') . " };");
// default state
$filter = 'all';
$do_regions = false;
$show_shared = true;
if (isset($_GET['filter']) && $_GET['filter'] == 'new') {
    $filter = 'new';
    $do_regions = true;
    $do_list_collapse = false;
    $show_shared = false;
}
if (isset($_GET['template']) && $_GET['template'] != '') {
    $filter = 'template';
    $do_regions = true;
    $do_list_collapse = false;
    $show_shared = true;
    $template_to_filter = urldecode($_GET['template']);
}
// Get pages
if ($do_list_collapse) {
    $expand_list = array(0);
    // get the existing expand list
示例#2
0
<?php

if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    $region_id = (int) $_GET['id'];
    $item_id = (int) $_GET['itm'];
    $Regions = new PerchContent_Regions();
    $Region = $Regions->find($region_id);
    $Pages = new PerchContent_Pages();
    $Page = $Pages->find($Region->pageID());
}
if (!$Region || !is_object($Region)) {
    PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content');
}
// set the current user
$Region->set_current_user($CurrentUser->id());
/* --------- Delete Form ----------- */
$Form = new PerchForm('delete');
if ($Form->posted() && $Form->validate() && isset($item_id)) {
    $Region->delete_item($item_id);
    $Region->index();
    if ($Form->submitted_via_ajax) {
        echo PERCH_LOGINPATH . '/core/apps/content/edit/?id=' . $Region->id();
        exit;
    } else {
        PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/edit/?id=' . $Region->id());
    }
}
 private function get_content_latest_revision($page = false)
 {
     if ($page === false) {
         $Perch = Perch::fetch();
         $page = $Perch->get_page();
     }
     $Regions = new PerchContent_Regions();
     $regions = $Regions->get_for_page_path($page);
     if (PerchUtil::count($regions)) {
         $out = array();
         foreach ($regions as $Region) {
             if ($this->preview && $Region->id() == $this->preview_contentID && $this->preview_rev != false) {
                 $out[$Region->regionKey()] = $Region->render($this->preview_rev);
             } else {
                 $out[$Region->regionKey()] = $Region->render();
             }
         }
         return $out;
     } else {
         return array();
     }
 }
示例#4
0
<?php

include 'PerchContent_Pages.class.php';
include 'PerchContent_Page.class.php';
include 'PerchContent_Regions.class.php';
include 'PerchContent_Region.class.php';
$Pages = new PerchContent_Pages();
$pages = $Pages->get_by_parent(0);
$Regions = new PerchContent_Regions();
$shared = $Regions->get_shared();
?>
<div class="widget">
	<h2>
		<?php 
echo PerchLang::get('Pages');
if ($CurrentUser->has_priv('content.pages.create')) {
    echo '<a href="' . PerchUtil::html(PERCH_LOGINPATH . '/core/apps/content/page/add/') . '" class="add button">' . PerchLang::get('Add Page') . '</a>';
}
?>
	</h2>
	<div class="bd">
		<?php 
if (PerchUtil::count($pages)) {
    echo '<ul>';
    if (PerchUtil::count($shared)) {
        echo '<li>';
        echo '<a href="' . PerchUtil::html(PERCH_LOGINPATH) . '/core/apps/content/page/?id=-1">';
        echo PerchUtil::html(PerchLang::get('Shared'));
        echo '</a>';
        echo '</li>';
    }
 /**
  * Make a region into a shared region
  *
  * @return void
  * @author Drew McLellan
  */
 public function make_shared()
 {
     $data = array();
     $data['regionPage'] = '*';
     $this->update($data);
     $Regions = new PerchContent_Regions();
     $Regions->delete_with_key($this->regionKey(), true);
     $Perch = Perch::fetch();
     $Perch->event('region.share', $this);
 }
示例#6
0
<?php

if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    $id = (int) $_GET['id'];
    $Regions = new PerchContent_Regions();
    $Region = $Regions->find($id);
    $Pages = new PerchContent_Pages();
    if (is_object($Region)) {
        if ($Region->regionPage() == '*') {
            $Page = $Pages->get_mock_shared_page();
        } else {
            $Page = $Pages->find($Region->pageID());
        }
    }
}
if (!$Region || !is_object($Region)) {
    PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content');
}
// Check permission to delete
if ($CurrentUser->has_priv('content.regions.delete') || $CurrentUser->has_priv('content.pages.delete.own') && $Page->pageCreatorID() == $CurrentUser->id()) {
    // we're ok.
} else {
    PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content');
}
/* --------- Delete Form ----------- */
$Form = new PerchForm('delete');
if ($Form->posted() && $Form->validate()) {
    $Region->delete();
    if ($Form->submitted_via_ajax) {
        echo PERCH_LOGINPATH . '/core/apps/content/page/?id=' . $Page->id();
        exit;
示例#7
0
<?php

include PERCH_PATH . '/core/apps/content/PerchContent_Regions.class.php';
include PERCH_PATH . '/core/apps/content/PerchContent_Region.class.php';
include PERCH_PATH . '/core/apps/content/PerchContent_Pages.class.php';
include PERCH_PATH . '/core/apps/content/PerchContent_Page.class.php';
$Roles = new PerchUserRoles();
$Regions = new PerchContent_Regions();
$Pages = new PerchContent_Pages();
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    $id = (int) $_GET['id'];
    $Role = $Roles->find($id);
} else {
    $id = false;
    $Role = false;
}
if (!is_object($Role)) {
    PerchUtil::redirect(PERCH_LOGINPATH . '/core/users/roles/');
}
$Form = new PerchForm('action', false);
if ($Form->posted() && $Form->validate()) {
    PerchUtil::debug($_POST);
    $action = false;
    if (isset($_POST['regions']) && $_POST['regions'] != '' && $_POST['regions'] != 'noaction') {
        if ($_POST['regions'] == 'grant') {
            $Regions->modify_permissions('grant', $Role->id());
        }
        if ($_POST['regions'] == 'revoke') {
            $Regions->modify_permissions('revoke', $Role->id());
        }
        $action = true;
 public function render_inputs($details = array())
 {
     $Perch = Perch::fetch();
     $page = false;
     // Find the path path.
     //
     // Has it been set as an attribute?
     if ($this->Tag->page()) {
         $page = $this->Tag->page();
     }
     // Has the PageID been set from the edit page?
     if (!$page && $this->Tag->page_id()) {
         $Pages = new PerchContent_Pages();
         $Page = $Pages->find($this->Tag->page_id());
         if ($Page) {
             $page = $Page->pagePath();
         }
     }
     // Use the current page.
     if (!$page) {
         $page = $Perch->get_page();
     }
     $region = $this->Tag->region();
     $field_id = $this->Tag->options();
     $values_id = $this->Tag->values();
     if (!class_exists('PerchContent_Regions', false)) {
         include_once PERCH_CORE . '/apps/content/PerchContent_Regions.class.php';
         include_once PERCH_CORE . '/apps/content/PerchContent_Items.class.php';
         include_once PERCH_CORE . '/apps/content/PerchContent_Item.class.php';
     }
     $Regions = new PerchContent_Regions();
     $opts = $Regions->find_data_select_options($page, $region, $field_id, $values_id);
     if (PerchUtil::bool_val($this->Tag->allowempty()) == true) {
         array_unshift($opts, array('label' => '', 'value' => ''));
     }
     return $this->Form->select($this->Tag->input_id(), $opts, $this->Form->get($details, $this->Tag->id(), $this->Tag->default(), $this->Tag->post_prefix()));
 }
     $PageTemplate = $PageTemplates->find($data['templateID']);
     if ($PageTemplate) {
         $data['pageTemplate'] = $PageTemplate->templatePath();
     } else {
         $data['pageTemplate'] = '';
     }
 }
 $Page->update($data);
 if (isset($_POST['pageParentID'])) {
     $parentID = (int) $_POST['pageParentID'];
     if ($parentID != $Page->pageParentID()) {
         $Page->update_tree_position($parentID, false, $cascade = true);
     }
 }
 // update regions on this page
 $Regions = new PerchContent_Regions();
 $regions = $Regions->get_for_page($Page->id());
 if (PerchUtil::count($regions)) {
     foreach ($regions as $Region) {
         if ($Region->regionPage() != '*') {
             $region_data = array();
             $region_data['regionPage'] = $data['pagePath'];
             $Region->update($region_data);
         }
     }
 }
 // navgroups
 if (isset($_POST['navgroups']) && PerchUtil::count($_POST['navgroups'])) {
     $Page->update_navgroups($_POST['navgroups']);
 } else {
     $Page->remove_from_navgroups();
示例#10
0
$republish = false;
$sql = "SHOW TABLES LIKE '__PREFIX__content_index'";
$sql = str_replace('__PREFIX__', PERCH_DB_PREFIX, $sql);
$row = $DB->get_row($sql);
if ($row == false) {
    $republish = true;
}
// CREATE NEW TABLES
$sql = "CREATE TABLE IF NOT EXISTS `__PREFIX__content_index` (\n\t\t\t  `indexID` int(10) NOT NULL AUTO_INCREMENT,\n\t\t\t  `itemID` int(10) NOT NULL DEFAULT '0',\n\t\t\t  `regionID` int(10) NOT NULL DEFAULT '0',\n\t\t\t  `pageID` int(10) NOT NULL DEFAULT '0',\n\t\t\t  `itemRev` int(10) NOT NULL DEFAULT '0',\n\t\t\t  `indexKey` char(64) NOT NULL DEFAULT '-',\n\t\t\t  `indexValue` char(255) NOT NULL DEFAULT '',\n\t\t\t  PRIMARY KEY (`indexID`),\n\t\t\t  KEY `idx_key` (`indexKey`),\n\t\t\t  KEY `idx_val` (`indexValue`),\n\t\t\t  KEY `idx_rev` (`itemRev`),\n\t\t\t  KEY `idx_item` (`itemID`),\n\t\t\t  KEY `idx_keyval` (`indexKey`,`indexValue`),\n\t\t\t  KEY `idx_regrev` (`regionID`,`itemRev`)\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;\n\n\t\tCREATE TABLE IF NOT EXISTS `__PREFIX__resources` (\n\t\t  `resourceID` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t  `resourceApp` char(32) NOT NULL DEFAULT 'content',\n\t\t  `resourceBucket` char(16) NOT NULL DEFAULT 'default',\n\t\t  `resourceFile` char(255) NOT NULL DEFAULT '',\n\t\t  `resourceKey` enum('orig','thumb') DEFAULT NULL,\n\t\t  `resourceParentID` int(10) NOT NULL DEFAULT '0',\n\t\t  `resourceType` char(4) NOT NULL DEFAULT '',\n\t\t  PRIMARY KEY (`resourceID`),\n\t\t  UNIQUE KEY `idx_file` (`resourceBucket`,`resourceFile`),\n\t\t  KEY `idx_app` (`resourceApp`),\n\t\t  KEY `idx_key` (`resourceKey`),\n\t\t  KEY `idx_type` (`resourceType`)\n\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;\n\n\t\t\n\t\tALTER TABLE `__PREFIX__content_items` ADD INDEX `idx_regrev` USING BTREE (itemID, regionID, itemRev);\n\n\t\tALTER TABLE `__PREFIX__content_items` ADD INDEX `idx_order` USING BTREE (itemOrder);\n\t\t\n\t\tALTER TABLE `__PREFIX__content_regions` ADD INDEX `idx_key` USING BTREE (regionKey);\n\t\t\n\t\tALTER TABLE `__PREFIX__content_regions` ADD INDEX `idx_path` USING BTREE (regionPage);\n\n\t\tALTER TABLE `__PREFIX__page_templates` ADD `templateNavGroups` VARCHAR(255)  NULL  DEFAULT ''  AFTER `templateReference`;\n\n\t\tCREATE TABLE IF NOT EXISTS `__PREFIX__navigation` (\n\t\t  `groupID` int(10) NOT NULL AUTO_INCREMENT,\n\t\t  `groupTitle` varchar(255) NOT NULL DEFAULT '',\n\t\t  `groupSlug` varchar(255) NOT NULL DEFAULT '',\n\t\t  PRIMARY KEY (`groupID`)\n\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;\n\n\t\tCREATE TABLE IF NOT EXISTS `__PREFIX__navigation_pages` (\n\t\t  `navpageID` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t  `pageID` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t  `groupID` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t  `pageParentID` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t  `pageOrder` int(10) unsigned NOT NULL DEFAULT '1',\n\t\t  `pageDepth` tinyint(10) unsigned NOT NULL,\n\t\t  `pageTreePosition` varchar(64) NOT NULL DEFAULT '',\n\t\t  PRIMARY KEY (`navpageID`),\n\t\t  KEY `idx_group` (`groupID`),\n\t\t  KEY `idx_page_group` (`pageID`,`groupID`)\n\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;\n\n\n\t\tALTER TABLE `__PREFIX__user_privileges` ADD UNIQUE INDEX `idx_key` (`privKey`);\n\n\t\tINSERT INTO `__PREFIX__user_privileges` (`privKey`, `privTitle`, `privOrder`)\n\t\tVALUES \n\t\t\t('content.navgroups.configure','Configure navigation groups',7),\n\t\t\t('content.navgroups.create','Create navigation groups',8),\n\t\t\t('content.navgroups.delete','Delete navigation groups',9);\n\n\t\tINSERT INTO `__PREFIX__user_privileges` (`privKey`, `privTitle`, `privOrder`)\n\t\tVALUES ('content.pages.create.toplevel','Add new top-level pages',3);\n\n\t\tINSERT INTO `__PREFIX__user_privileges` (`privKey`, `privTitle`, `privOrder`)\n\t\tVALUES ('content.pages.delete.own','Delete pages they created themselves',4);\n\t\t\n\t\tINSERT INTO `__PREFIX__user_privileges` (`privKey`, `privTitle`, `privOrder`)\n\t\tVALUES ('content.templates.configure','Configure master pages',6);\n\n\n\t\tINSERT INTO `__PREFIX__user_privileges` (`privKey`, `privTitle`, `privOrder`)\n\t\tVALUES \n\t\t\t('content.pages.republish','Republish pages', 12);\n\n\t\tALTER TABLE `__PREFIX__pages` ADD `pageAccessTags` VARCHAR(255)  NOT NULL  DEFAULT ''  AFTER `pageNavOnly`;\n\n\t\tALTER TABLE `__PREFIX__pages` ADD `pageCreatorID` INT(10)  UNSIGNED  NOT NULL  DEFAULT '0'  AFTER `pageAccessTags`;\n\n\t\tALTER TABLE `__PREFIX__pages` ADD `pageModified` DATETIME  NOT NULL DEFAULT '2014-01-01 00:00:00' AFTER `pageCreatorID`;\n\n\t\tALTER TABLE `__PREFIX__pages` ADD `pageAttributes` TEXT  NOT NULL  AFTER `pageModified`;\n\n\t\tALTER TABLE `__PREFIX__pages` ADD `pageAttributeTemplate` VARCHAR(255)  NOT NULL  DEFAULT 'default.html'  AFTER `pageAttributes`;\n\n\t\tINSERT INTO `__PREFIX__user_privileges` (`privKey`, `privTitle`, `privOrder`)\n\t\tVALUES ('content.pages.attributes','Edit page titles and attributes',6);\n\t\t\n\n\t\tCREATE TABLE IF NOT EXISTS `__PREFIX__user_role_privileges` (\n\t\t  `roleID` int(10) unsigned NOT NULL,\n\t\t  `privID` int(10) unsigned NOT NULL,\n\t\t  PRIMARY KEY (`roleID`,`privID`)\n\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;\n\n\t";
$sql = str_replace('__PREFIX__', PERCH_DB_PREFIX, $sql);
$queries = explode(';', $sql);
if (PerchUtil::count($queries) > 0) {
    foreach ($queries as $query) {
        $query = trim($query);
        if ($query != '') {
            $DB->execute($query);
            if ($DB->errored && strpos($DB->error_msg, 'Duplicate') === false) {
                echo '<li class="icon failure error">' . PerchUtil::html(PerchLang::get('The following error occurred:')) . '</li>';
                echo '<li class="failure"><code class="sql">' . PerchUtil::html($query) . '</code></li>';
                echo '<li class="failure"><code>' . PerchUtil::html($DB->error_msg) . '</code></p></li>';
                $errors = true;
            }
        }
    }
}
if (!$errors && $republish) {
    PerchUtil::debug('Republishing');
    $Regions = new PerchContent_Regions();
    $Regions->republish_all();
}
示例#11
0
<?php

$Pages = new PerchContent_Pages();
$Regions = new PerchContent_Regions();
$Page = false;
$collections = false;
// Find the page
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    $id = (int) $_GET['id'];
    if ($id == -1) {
        $Page = $Pages->get_mock_shared_page();
    } else {
        $Page = $Pages->find($id);
    }
}
// Check we have a page
if (!$Page || !is_object($Page)) {
    PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/');
}
if (PERCH_RUNWAY) {
    $Collections = new PerchContent_Collections();
    if ($Page->pageCollections()) {
        $collections = $Collections->get_by_id_string($Page->pageCollections());
    }
}
if ($Page->pagePath() == '*') {
    $regions = $Regions->get_shared();
} else {
    $regions = $Regions->get_for_page($Page->id(), $include_shared = false);
}