本文整理汇总了PHP中Sections::FindByName方法的典型用法代码示例。如果您正苦于以下问题:PHP Sections::FindByName方法的具体用法?PHP Sections::FindByName怎么用?PHP Sections::FindByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sections
的用法示例。
在下文中一共展示了Sections::FindByName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display_page_content
function display_page_content()
{
$section_name = requestIdParam();
$section = Sections::FindByName($section_name);
$items = $section->findItems();
?>
<div id="right">
<h3>Item Thumbnail</h3>
</div>
<div id="center">
<h3>All the <?php
echo $section->display_name;
?>
</h3>
<?php
echo $section->content;
?>
<?php
echo "<ul>\r\n";
foreach ($items as $item) {
echo "\t\t\t<li><a href=\"" . get_link("portfolio/item/{$section_name}/" . $item->name) . "\">{$item->display_name}</a></li>\r\n";
}
echo "\t\t</ul>\r\n";
?>
</div>
<?php
}
示例2: display_page_content
function display_page_content()
{
$section_name = requestIdParam();
$section = Sections::FindByName($section_name);
$item_name = getRequestVarAtIndex(3);
$item = Items::FindByName($item_name);
$gallery = $item->getGallery();
?>
<h1><?php
echo $item->display_name;
?>
</h1>
<?php
$next_item = $item->findNext($section);
$prev_item = $item->findPrev($section);
if ($prev_item) {
echo "\t\t\t\t<a href=\"" . get_link("portfolio/item/{$section_name}/" . $prev_item->name) . "\">previous</a>\n";
}
if ($next_item) {
echo "\t\t\t\t<a href=\"" . get_link("portfolio/item/{$section_name}/" . $next_item->name) . "\">next</a>\n";
}
echo $item->content;
foreach ($gallery->get_photos() as $photo) {
echo "<img src=\"/" . $photo->getPublicUrl() . "\" /><br />";
}
}
示例3: FindBySectionName
function FindBySectionName($section_name = "")
{
if ($section_name == "") {
return array();
}
$section = Sections::FindByName($section_name);
$items = $section->findItems();
$id_list = "";
foreach ($items as $item) {
$id_list .= "{$item->id},";
}
$id_list = trim($id_list, ',');
return MyActiveRecord::FindBySql('Keywords', "SELECT DISTINCT k.* FROM keywords k inner join items_keywords ik ON ik.keywords_id = k.id and ik.items_id in ({$id_list})");
}
示例4: display_page
function display_page($params = array())
{
// canonicalize the input
$area_name = $page_name = "";
// GET /
if (count($params) == 0) {
$area_name = "index";
$page_name = "index";
}
// GET /area_name
if (count($params) == 1) {
$area_name = $params[0];
$page_name = "index";
}
// GET /area_name/page_name
if (count($params) > 1) {
$area_name = $params[0];
$page_name = $params[1];
}
if (ALIAS_INSTALL) {
// Test the MyActiveRecord connection
if (mysql_num_rows(mysql_query("SHOW TABLES LIKE 'alias'")) == 1) {
// check the alias' in the database and see if there is a match
$alias = Alias::FindAll();
/* die(print_r($alias)); */
foreach ($alias as $entry) {
if ($entry->alias == $area_name || $entry->alias == "/" . $area_name) {
redirect($entry->path);
}
}
}
}
// check the routes to see if the requested page has an explicit route setup
$page_options = $GLOBALS['ROUTES'];
if (isset($page_options["/" . $area_name . "/" . $page_name])) {
$page = StaticPage::FindByAreaAndName($area_name, $page_name);
if (isset($page)) {
display_admin_with_template($page);
return true;
}
}
// check for pages that are in the "global" area and have params (ie /calendar/2008/1)
$global_area = Areas::FindByName('index');
$possible_page = Pages::FindByAreaAndName($global_area, $page_name) ? Pages::FindByAreaAndName($global_area, $area_name) : '';
if (!empty($possible_page)) {
$area = $global_area;
$page = $possible_page;
} else {
// for now, just include the first page that comes back. later we can handle multiple pages
$area = Areas::FindByName($area_name);
if (!isset($area)) {
return false;
}
if (strstr($area_name, "-portfolio")) {
if ($page_name != "index") {
$page = Sections::FindByName($page_name);
} else {
$pages = $area->getSections();
$page = array_shift($pages);
}
} else {
$page = Pages::FindPageOrIndex($area, $page_name);
}
}
if (!isset($page)) {
return false;
}
// check if the page is public or not
$is_admin = false;
$user = Users::GetCurrentUser();
if ($user) {
$logged_in = true;
}
if ($page->public || !$page->public && $logged_in) {
display_with_template($area, $page);
} else {
return false;
}
return true;
}
示例5: initialize_page
function initialize_page()
{
$item = Items::FindById(getRequestVaratIndex(3));
// get all the sections
$sections = Sections::FindPublicSections();
/* get this section
* We do this mostly for the previous and next item functions. If we dont know what section we are currently inside,
* the user may get bounced over to a different place than they started. */
$sectionname = getRequestVaratIndex(2);
if ($sectionname != "item_orphan") {
$section = Sections::FindByName($sectionname);
}
// get the associated gallery
if ($item) {
$gallery = $item->getGallery();
}
// finally, get the post action. Harder to hack if we explicitly check the value this way.
$post_action = "";
if (isset($_POST['submit'])) {
$post_action = $_POST['submit'];
}
if ($post_action == "Save Item" || $post_action == "Add Image" || $post_action == "Add Document" || $post_action == "Add or Edit Video" || $post_action == "Save and Return to List") {
/*
* Delete this item and its associated components
*/
if (isset($_POST['delete'])) {
// delete $photos and $gallery
if (is_object($gallery)) {
$gallery->delete(true);
$success .= "Gallery and Images Deleted / ";
}
/* Documents ... Why not keep them?
if ( ITEM_DOCUMENTS ) {
$itemdocuments = $item->findDocuments( 'display_order ASC' );
foreach ( $itemdocuments as $thedoc ) {
$thedoc->delete(true);
}
$success .= "Documents Deleted / ";
}*/
$item->delete(true);
$success .= "Item Deleted / ";
setFlash("<h3>" . substr($success, 0, -3) . "</h3>");
//$main_portlink = ( DISPLAY_ITEMS_AS_LIST ) ? "admin/portfolio_list/alphabetical" : "admin/portfolio_list";
//redirect( $main_portlink );
redirect("admin/portfolio_list");
} else {
$item->content = $_POST['item_content'];
$item->display_name = $_POST['display_name'];
$previous_name = $item->name;
$item->name = slug($_POST['display_name']);
$item->template = 'inherit';
$item->public = checkboxValue($_POST, 'public');
$item->date_revised = date('Y-m-d H:i:s');
// optional fields
$item->sku = ITEM_SKU ? $_POST['item_sku'] : null;
$item->taxonomy = ITEM_TAXONOMY ? $_POST['taxonomy'] : null;
$item->price = ITEM_PRICE ? $_POST['item_price'] : null;
// SAVE item... uses a MyActiveRecord method
$item->save();
$success = "Item Saved / ";
// synchronize the users section selections only if they are different
$selected_sections = array();
$previous_sections = $item->getSections();
if (isset($_POST['selected_sections'])) {
$update_sections = false;
$selected_sections = $_POST['selected_sections'];
// Problem: If we loop on only the $previous_sections, we may have fewer or more loops than $selected_sections.
// Compare one to the other.
if (count($previous_sections) != count($selected_sections)) {
// The two do not match, so there has been a change
$update_sections = true;
} else {
// In case the two match, let's make sure something is different.
foreach ($previous_sections as $sect) {
if (!in_array($sect->id, $selected_sections)) {
$update_sections = true;
}
}
}
if ($update_sections) {
$item->updateSelectedSections($selected_sections);
// update the revision dates of sections, too
$item->updateSectionRevisionDates();
}
}
/*
* Rename the gallery if the slug has changed.
* We need the name of the gallery and the name of the slug to be consistent.
* If there isn't a gallery – something broke, so – create a new one.
*/
if (is_object($gallery) && $previous_name != $item->name) {
$gallery->slug = "portfolioGal_" . $item->id . "_" . $item->name;
$gallery->save();
$success .= "Gallery name changed / ";
}
if (!is_object($gallery)) {
$gallery = MyActiveRecord::Create('Galleries');
$gallery->name = $_POST['display_name'] . " Gallery";
$gallery->slug = "portfolioGal_" . $item->id . "_" . slug($_POST['display_name']);
$gallery->save();
//.........这里部分代码省略.........