当前位置: 首页>>代码示例>>PHP>>正文


PHP Surfer类代码示例

本文整理汇总了PHP中Surfer的典型用法代码示例。如果您正苦于以下问题:PHP Surfer类的具体用法?PHP Surfer怎么用?PHP Surfer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Surfer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: layout

 /**
  * list users
  *
  * @param resource the SQL result
  * @return array of ($nick_name => $more)
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of ($nick_name => $more)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // unique identifier
         $key = $item['nick_name'];
         // use the full name, if nick name is not part of it
         $more = '';
         if ($item['full_name'] && !preg_match('/\\b' . preg_quote($item['nick_name'], '/') . '\\b/', $item['full_name'])) {
             $more = ucfirst($item['full_name']) . ' ';
         }
         // else use e-mail address, if any --but only to authenticated surfer
         if ($item['email'] && Surfer::is_logged()) {
             if ($more) {
                 $more .= '<' . $item['email'] . '>';
             } else {
                 $more .= $item['email'];
             }
         } elseif ($item['introduction']) {
             $more .= $item['introduction'];
         }
         // record this item
         $items[$key] = $more;
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
开发者ID:rair,项目名称:yacs,代码行数:43,代码来源:layout_users_as_complete.php

示例2: get_fields

 /**
  * preserve content across page modification
  *
  * @see overlays/overlay.php
  *
  * @param the hosting attributes
  * @return a list of ($label, $input, $hint)
  */
 function get_fields($host, $field_pos = NULL)
 {
     global $context;
     // form fields
     $fields = array();
     // item identifier
     if (!isset($this->attributes['overlay_id'])) {
         $this->attributes['overlay_id'] = '';
     }
     // only associates can change the overlay id
     if (Surfer::is_associate()) {
         // isset($host['anchor']) && ($parent =&  Anchors::get($host['anchor'])) && $parent->is_assigned()) {
         $label = i18n::s('Overlay identifier');
         $input = '<input type="text" name="overlay_id" value="' . encode_field($this->attributes['overlay_id']) . '" />';
     } else {
         $label = 'hidden';
         $input = '<input type="hidden" name="overlay_id" value="' . encode_field($this->attributes['overlay_id']) . '" />';
     }
     // hidden attributes
     foreach ($this->attributes as $name => $value) {
         if (preg_match('/_content$/', $name)) {
             $input .= '<input type="hidden" name="' . encode_field($name) . '" value="' . encode_field($value) . '" />';
         }
     }
     // we do have something to preserve
     $fields[] = array($label, $input);
     // job done
     return $fields;
 }
开发者ID:rair,项目名称:yacs,代码行数:37,代码来源:mutable.php

示例3: get_comment_notification

 public function get_comment_notification($item)
 {
     global $context;
     // build a tease notification for simple members
     // sanity check
     if (!isset($item['anchor']) || !($anchor = Anchors::get($item['anchor']))) {
         throw new Exception('no anchor for this comment');
     }
     // headline
     $headline = sprintf(i18n::c('%s has replied'), Surfer::get_link());
     $content = BR;
     // shape these
     $tease = Skin::build_mail_content($headline, $content);
     // a set of links
     $menu = array();
     // call for action
     $link = $context['url_to_home'] . $context['url_to_root'] . Comments::get_url($item['id'], 'view');
     $menu[] = Skin::build_mail_button($link, i18n::c('View the reply'), TRUE);
     // link to the container
     $menu[] = Skin::build_mail_button($anchor->get_url(), $anchor->get_title(), FALSE);
     // finalize links
     $tease .= Skin::build_mail_menu($menu);
     // assemble all parts of the mail
     $mail = array();
     $mail['subject'] = sprintf(i18n::c('%s: %s'), i18n::c('Reply in the discussion'), strip_tags($anchor->get_title()));
     $mail['notification'] = Comments::build_notification($item);
     // full notification
     $mail['tease'] = Mailer::build_notification($tease, 1);
     return $mail;
 }
开发者ID:rair,项目名称:yacs,代码行数:30,代码来源:thread.php

示例4: layout

 /**
  * list servers
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // initialize variables
         $prefix = $suffix = $icon = '';
         // the url to view this item
         $url = Servers::get_url($item['id']);
         // use the title as a label
         $label = Skin::strip($item['title'], 10);
         // flag files uploaded recently
         if ($item['edit_date'] >= $context['fresh']) {
             $prefix = NEW_FLAG . $prefix;
         }
         // description
         if ($item['description']) {
             $suffix .= ' ' . ucfirst(trim($item['description']));
         }
         // the menu bar for associates and poster
         if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
             $menu = array(Servers::get_url($item['id'], 'edit') => i18n::s('Edit'), Servers::get_url($item['id'], 'delete') => i18n::s('Delete'));
             $suffix .= ' ' . Skin::build_list($menu, 'menu');
         }
         // add a separator
         if ($suffix) {
             $suffix = ' - ' . $suffix;
         }
         // append details to the suffix
         $suffix .= BR . '<span class="details">';
         // details
         $details = array();
         // item poster
         if ($item['edit_name']) {
             $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
         }
         // the edition date
         $details[] = Skin::build_date($item['edit_date']);
         // all details
         if (count($details)) {
             $suffix .= ucfirst(implode(', ', $details)) . "\n";
         }
         // end of details
         $suffix .= '</span>';
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'server', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
开发者ID:rair,项目名称:yacs,代码行数:66,代码来源:layout_servers.php

示例5: layout

 /**
  * list comments as successive notes in a thread
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // we return formatted text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // build a list of comments
     while ($item = SQL::fetch($result)) {
         // automatic notification
         if ($item['type'] == 'notification') {
             $text = '<dd class="thread_other" style="font-style: italic;">' . ucfirst(trim($item['description'])) . '</dd>' . $text;
         } else {
             // link to user profile -- open links in separate window to enable side browsing of participant profiles
             if ($item['create_id']) {
                 if ($user = Users::get($item['create_id']) && $user['full_name']) {
                     $hover = $user['full_name'];
                 } else {
                     $hover = NULL;
                 }
                 $author = Users::get_link($item['create_name'], $item['create_address'], $item['create_id'], TRUE, $hover);
             } else {
                 $author = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id'], TRUE);
             }
             // differentiate my posts from others
             if (Surfer::get_id() && $item['create_id'] == Surfer::get_id()) {
                 $style = ' class="thread_me"';
             } else {
                 $style = ' class="thread_other"';
             }
             // a clickable label
             $stamp = '#';
             // flag old items on same day
             if (!strncmp($item['edit_date'], gmstrftime('%Y-%m-%d %H:%M:%S', time()), 10)) {
                 $stamp = Skin::build_time($item['edit_date']);
             } else {
                 $stamp = Skin::build_date($item['edit_date']);
             }
             // append this at the end of the comment
             $stamp = ' <div style="float: right; font-size: x-small">' . Skin::build_link(Comments::get_url($item['id']), $stamp, 'basic', i18n::s('Edit')) . '</div>';
             // package everything --change order to get oldest first
             $text = '<dt' . $style . '>' . $author . '</dt><dd' . $style . '>' . $stamp . ucfirst(trim($item['description'])) . '</dd>' . $text;
         }
     }
     // end of processing
     SQL::free($result);
     // finalize the returned definition list
     if ($text) {
         $text = '<dl>' . $text . '</dl>';
     }
     // process yacs codes
     $text = Codes::beautify($text);
     return $text;
 }
开发者ID:rair,项目名称:yacs,代码行数:62,代码来源:layout_comments_as_thread.php

示例6: add_commands

 /**
  * extend the page menu
  *
  * @param string script name
  * @param string target anchor, if any
  * @param array current menu
  * @return array updated menu
  */
 function add_commands($script, $anchor, $menu = array())
 {
     global $context;
     // limit the scope of our check to viewed pages
     if (!preg_match('/articles\\/view/', $script)) {
         return $menu;
     }
     // surfer has to be authenticated
     if (!Surfer::is_logged()) {
         return $menu;
     }
     // sanity checks
     if (!$anchor) {
         Logger::error(i18n::s('No anchor has been found.'));
     } elseif (!($target = Anchors::get($anchor))) {
         Logger::error(i18n::s('No anchor has been found.'));
     } elseif (!$this->parameters) {
         Logger::error(sprintf(i18n::s('No parameter has been provided to %s'), 'behaviors/move_on_article_access'));
     } else {
         // look at parent container if possible
         if (!($origin = Anchors::get($target->get_parent()))) {
             $origin = $target;
         }
         // only container editors can proceed
         if ($origin->is_assigned() || Surfer::is_associate()) {
             // load target section
             $tokens = explode(' ', $this->parameters, 2);
             if ($section = Anchors::get('section:' . $tokens[0])) {
                 // make a label
                 if (count($tokens) < 2) {
                     $tokens[1] = sprintf(i18n::s('Move to %s'), $section->get_title());
                 }
                 // the target link to move the page
                 $link = Articles::get_url(str_replace('article:', '', $anchor), 'move', str_replace('section:', '', $section->get_reference()));
                 // make a sub-menu
                 $menu = array_merge(array($link => array('', $tokens[1], '', 'button')), $menu);
             }
         }
     }
     return $menu;
 }
开发者ID:rair,项目名称:yacs,代码行数:49,代码来源:move_on_article_access.php

示例7: get_fields

 /**
  * get form fields to change the day
  *
  * @see overlays/overlay.php
  *
  * @param array hosting attributes
  * @return a list of ($label, $input, $hint)
  */
 function get_fields($host, $field_pos = NULL)
 {
     global $context;
     $options = '<input type="hidden" name="time_stamp" value="12:00" />' . '<input type="hidden" name="duration" value="1440" />';
     // default value is now
     if (!isset($this->attributes['date_stamp']) || $this->attributes['date_stamp'] <= NULL_DATE) {
         $this->attributes['date_stamp'] = gmstrftime('%Y-%m-%d %H:%M', time() + Surfer::get_gmt_offset() * 3600);
     } else {
         $this->attributes['date_stamp'] = Surfer::from_GMT($this->attributes['date_stamp']);
     }
     // split date from time
     list($date, $time) = explode(' ', $this->attributes['date_stamp']);
     // event time
     $label = i18n::s('Date');
     $input = Skin::build_input_time('date_stamp', $date, 'date') . $options;
     $hint = i18n::s('Use format YYYY-MM-DD');
     $fields[] = array($label, $input, $hint);
     // ensure that we do have a date
     Page::insert_script('func' . 'tion validateOnSubmit(container) {' . "\n" . "\n" . '	if(!Yacs.trim(container.date_stamp.value)) {' . "\n" . '		alert("' . i18n::s('Please provide a date.') . '");' . "\n" . '		container.date_stamp.focus();' . "\n" . '		Yacs.stopWorking();' . "\n" . '		return false;' . "\n" . '	}' . "\n\n" . '	return true;' . "\n" . '}' . "\n");
     return $fields;
 }
开发者ID:rair,项目名称:yacs,代码行数:29,代码来源:day.php

示例8: array

    // the submit button
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . "\n" . Skin::finalize_list($menu, 'menu_bar') . '<input type="hidden" name="id" value="' . $item['id'] . '" />' . "\n" . '<input type="hidden" name="confirm" value="yes" />' . "\n" . '</p></form>' . "\n";
    // set the focus
    Page::insert_script('$("#confirmed").focus();');
    // the title of the table
    if (isset($item['title'])) {
        $context['text'] .= Skin::build_block($item['title'], 'title');
    }
    // display the full text
    $context['text'] .= Skin::build_block($item['description'], 'description');
    // execute the query string to build the table
    if (isset($item['query']) && $item['query']) {
        $context['text'] .= Tables::build($item['id'], 'sortable');
    }
    // display the query string, if any
    if (isset($item['query']) && $item['query']) {
        $context['text'] .= BR . '<pre>' . $item['query'] . '</pre>' . BR . "\n";
    }
    // details
    $details = array();
    // information on uploader
    if (Surfer::is_member() && $item['edit_name']) {
        $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
    }
    // all details
    if ($details) {
        $context['text'] .= '<p class="details">' . ucfirst(implode(', ', $details)) . '</p>' . "\n";
    }
}
// render the skin
render_skin();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:delete.php

示例9: die

// stop crawlers
if (Surfer::is_crawler()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    die(i18n::s('You are not allowed to perform this operation.'));
}
// page title
if (isset($item['title'])) {
    $context['page_title'] = $item['title'];
}
// not found
if (!$item['id']) {
    include '../error.php';
    // access denied
} elseif (!Sections::allow_access($item, $anchor)) {
    // give anonymous surfers a chance for HTTP authentication
    if (!Surfer::is_logged()) {
        Safe::header('WWW-Authenticate: Basic realm="' . utf8::to_iso8859($context['site_name']) . '"');
        Safe::header('Status: 401 Unauthorized', TRUE, 401);
    }
    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // describe the section
} else {
    // compute the url for this section
    $url = Sections::get_permalink($item);
    // get a description
    if ($item['introduction']) {
        $description = Codes::beautify($item['introduction']);
    } else {
        $description = Skin::strip(Codes::beautify($item['description']), 50);
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:describe.php

示例10: layout

 /**
  * list users
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!($count = SQL::count($result))) {
         return $text;
     }
     // allow for several lists in the same page
     static $serial;
     if (isset($serial)) {
         $serial++;
     } else {
         $serial = 1;
     }
     // don't blast too many people
     if ($count > 100) {
         $checked = '';
     } elseif (isset($this->layout_variant) && $this->layout_variant == 'unchecked') {
         $checked = '';
     } else {
         $checked = ' checked="checked"';
     }
     // div prefix
     $text .= '<div id="users_as_mail_panel_' . $serial . '">';
     // allow to select/deslect multiple rows at once
     $text .= '<input type="checkbox" class="row_selector" onclick="check_user_as_mail_panel_' . $serial . '(\'div#users_as_mail_panel_' . $serial . '\', this);"' . $checked . ' /> ' . i18n::s('Select all/none') . BR;
     // process all items in the list
     $count = 0;
     while ($item = SQL::fetch($result)) {
         // we need some address
         if (!$item['email']) {
             continue;
         }
         // do not write to myself
         if ($item['id'] == Surfer::get_id()) {
             continue;
         }
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'user:' . $item['id']);
         // column to select the row
         $text .= '<input type="checkbox" name="selected_users[]" class="row_selector" value="' . encode_field($item['email']) . '"' . $checked . ' />';
         // signal restricted and private users
         if ($item['active'] == 'N') {
             $text .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $text .= RESTRICTED_FLAG;
         }
         // the url to view this item
         $url = Users::get_permalink($item);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['full_name']);
         }
         // sanity check
         if (!$title) {
             $title = $item['nick_name'];
         }
         // link to this page
         $text .= Skin::build_link($url, $title, 'user');
         // the introductory text
         if ($item['introduction']) {
             $text .= '<span class="tiny"> - ' . Codes::beautify_introduction($item['introduction']) . '</span>';
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $text .= $overlay->get_text('list', $item);
         }
         // display all tags
         if ($item['tags']) {
             $text .= ' <span class="tags">' . Skin::build_tags($item['tags'], 'user:' . $item['id']) . '</span>';
         }
         // append the row
         $text .= BR;
         $count++;
     }
     // the script used to check all items at once
     Page::insert_script('function check_user_as_mail_panel_' . $serial . '(scope, handle) {' . "\n" . '	$(scope + " input[type=\'checkbox\'].row_selector").each(' . "\n" . '		function() { $(this).attr("checked", $(handle).is(":checked"));}' . "\n" . '	);' . "\n" . '}' . "\n");
     // div suffix
     $text .= '</div>';
     // no valid account has been found
     if (!$count) {
         $text = '';
     }
     // end of processing
     SQL::free($result);
     return $text;
 }
开发者ID:rair,项目名称:yacs,代码行数:99,代码来源:layout_users_as_mail.php

示例11: while

     $text .= ' ' . Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's');
     $text .= BR . '<span class="details">' . i18n::s('Select a .png, .gif or .jpeg image.') . ' (&lt;&nbsp;' . Skin::build_number($image_maximum_size, i18n::s('bytes')) . ')</span>';
     // end of the form
     $text .= '</div></form>';
     // the script used for form handling at the browser
     Page::insert_script('$("#upload").focus();');
     $context['text'] .= Skin::build_content(NULL, i18n::s('Upload an image'), $text);
 }
 // use the library
 //
 // where images are
 $path = 'skins/_reference/avatars';
 // browse the path to list directories and files
 if ($dir = Safe::opendir($context['path_to_root'] . $path)) {
     $text = '';
     if (Surfer::may_upload()) {
         $text .= '<p>' . i18n::s('Click on one image below to make it your new picture.') . '</p>' . "\n";
     }
     // build the lists
     while (($image = Safe::readdir($dir)) !== FALSE) {
         // skip some files
         if ($image[0] == '.') {
             continue;
         }
         if (is_dir($context['path_to_root'] . $path . '/' . $image)) {
             continue;
         }
         // consider only images
         if (!preg_match('/(\\.gif|\\.jpeg|\\.jpg|\\.png)$/i', $image)) {
             continue;
         }
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:select_avatar.php

示例12: stat

 /**
  * get some statistics
  *
  * @return the resulting ($count, $min_date, $max_date) array
  *
  * @see links/index.php
  */
 public static function stat()
 {
     global $context;
     // if not associate, restrict to links attached to public published not expired pages
     if (!Surfer::is_associate()) {
         $where = ", " . SQL::table_name('articles') . " AS articles " . " WHERE ((links.anchor_type LIKE 'article') AND (links.anchor_id = articles.id))" . " AND (articles.active='Y')" . " AND NOT ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))" . " AND ((articles.expiry_date is NULL)" . "\tOR (articles.expiry_date <= '" . NULL_DATE . "') OR (articles.expiry_date > '" . gmstrftime('%Y-%m-%d %H:%M:%S') . "'))" . " AND (links.edit_id > 0)";
     } else {
         $where = "WHERE (links.edit_id > 0)";
     }
     // select among available items
     $query = "SELECT COUNT(links.link_url) as count, MIN(links.edit_date) as oldest_date, MAX(links.edit_date) as newest_date" . " FROM " . SQL::table_name('links') . " AS links " . $where;
     $output = SQL::query_first($query);
     return $output;
 }
开发者ID:rair,项目名称:yacs,代码行数:21,代码来源:links.php

示例13: ucfirst

    }
    // page details
    if (is_array($details)) {
        $context['text'] .= '<p class="details">' . ucfirst(implode(', ', $details)) . "</p>\n";
    }
    // insert anchor suffix
    if (is_object($anchor)) {
        $context['text'] .= $anchor->get_suffix();
    }
    // back to the anchor page
    if (is_object($anchor) && $anchor->is_viewable()) {
        $menu = array(Skin::build_link($anchor->get_url(), i18n::s('Back to main page'), 'button'));
        $context['text'] .= Skin::build_block(Skin::finalize_list($menu, 'menu_bar'), 'bottom');
    }
    //
    // populate the extra panel
    //
    // commands for associates and editors
    if (Surfer::is_associate() || is_object($anchor) && $anchor->is_assigned()) {
        $context['page_tools'][] = Skin::build_link(Locations::get_url($id, 'edit'), i18n::s('Edit'));
        $context['page_tools'][] = Skin::build_link(Locations::get_url($id, 'delete'), i18n::s('Delete'));
        // commands for the author
    } elseif (Surfer::is($item['edit_id'])) {
        $context['page_tools'][] = Skin::build_link(Locations::get_url($item['id'], 'edit'), i18n::s('Edit'));
    }
    // referrals, if any, in a sidebar
    //
    $context['components']['referrals'] =& Skin::build_referrals(Locations::get_url($item['id']));
}
// render the skin
render_skin();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:view.php

示例14: elseif

// look for the id
$id = NULL;
if (isset($_REQUEST['id'])) {
    $id = $_REQUEST['id'];
} elseif (isset($context['arguments'][0])) {
    $id = $context['arguments'][0];
} elseif (Surfer::is_logged()) {
    $id = Surfer::get_id();
}
$id = strip_tags($id);
// get the item from the database
$item = Users::get($id);
// associates can do what they want
if (Surfer::is_associate()) {
    $permitted = TRUE;
} elseif ($item['active'] == 'R' && Surfer::is_member()) {
    $permitted = TRUE;
} elseif ($item['active'] == 'Y') {
    $permitted = TRUE;
} else {
    $permitted = FALSE;
}
// load the skin
load_skin('users');
// path to this page
$context['path_bar'] = array('users/' => i18n::s('People'));
// page title
$context['page_title'] = i18n::s('RSS feed');
// not found
if (!isset($item['id'])) {
    include '../error.php';
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:feed.php

示例15: layout

 /**
  * main function to render layout
  * 
  * @param type $result MySQL object
  * @return string the rendering
  */
 public function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // type of listed object
     $items_type = $this->listed_type;
     // this level root reference
     if (isset($this->focus) && $this->focus) {
         $root_ref = $this->focus;
     } elseif (isset($context['current_item']) && $context['current_item']) {
         $root_ref = $context['current_item'];
     } else {
         $root_ref = $items_type . ':index';
     }
     $this->tree_only = $this->has_variant('tree_only');
     // drag&drop zone
     $text .= '<div class="tm-ddz tm-drop" data-ref="' . $root_ref . '" data-variant="' . $this->layout_variant . '" >' . "\n";
     // root create command
     $text .= $this->btn_create();
     // root ul
     $text .= '<ul class="tm-sub_elems tm-root">' . "\n";
     while ($item = SQL::fetch($result)) {
         // get the object interface, this may load parent and overlay
         $entity = new $items_type($item);
         // title
         $title = '<a class="tm-zoom" href="' . $entity->get_permalink() . '"><span class="tm-folder">' . $entity->get_title() . '</span></a>';
         // sub elements of this entity
         $sub = $this->get_sub_level($entity);
         // command related to this entity
         $cmd = $this->get_interactive_menu();
         // one <li> per entity of this level of the tree
         $text .= '<li class="tm-drag tm-drop" data-ref="' . $entity->get_reference() . '">' . $title . $cmd . $sub . '</li>' . "\n";
     }
     // this level may have childs that are not folders (exept index)
     // do not search in variant tree_only is setted
     if (!preg_match('/index$/', $root_ref) && !$this->tree_only) {
         $thislevel = Anchors::get($root_ref);
         $text .= $this->get_sub_level($thislevel, true);
         // do not search for folders
     }
     // we have bound styles and scripts, but do not provide on ajax requests
     if (!isset($context['AJAX_REQUEST']) || !$context['AJAX_REQUEST']) {
         $this->load_scripts_n_styles();
         // init js depending on user privilege for this level
         if (isset($thislevel)) {
             // get surfer privilege for this level
             $powered = $thislevel->allows('creation');
         } else {
             $powered = Surfer::is_associate();
         }
         $powered = $powered ? 'powered' : '';
         // cast to string
         Page::insert_script('TreeManager.init("' . $powered . '");');
     }
     // end drag drop zone
     $text .= '</ul></div>' . "\n";
     // end of processing
     SQL::free($result);
     return $text;
 }
开发者ID:rair,项目名称:yacs,代码行数:67,代码来源:layout_as_tree_manager.php


注:本文中的Surfer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。