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


PHP Articles::allow_modification方法代码示例

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


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

示例1: allow_creation

 /**
  * check if new images can be added
  *
  * This function returns TRUE if images can be added to some place,
  * and FALSE otherwise.
  *
  * @param object an instance of the Anchor interface, if any
  * @param array a set of item attributes, if any
  * @param string the type of item, e.g., 'section'
  * @return TRUE or FALSE
  */
 public static function allow_creation($item = NULL, $anchor = NULL, $variant = NULL)
 {
     global $context;
     // backward compatibility, reverse parameters :
     // $anchor is always a object and $item a array
     if (is_object($item) || is_array($anchor)) {
         $permute = $anchor;
         $anchor = $item;
         $item = $permute;
     }
     // guess the variant
     if (!$variant) {
         // most frequent case
         if (isset($item['id'])) {
             $variant = 'article';
         } elseif (is_object($anchor)) {
             $variant = $anchor->get_type();
         } else {
             return FALSE;
         }
     }
     // only in articles
     if ($variant == 'article') {
         // 'no images' option
         if (Articles::has_option('no_images', $anchor, $item)) {
             return FALSE;
         }
         // other containers
     } else {
         // in item
         if (isset($item['options']) && is_string($item['options']) && preg_match('/\\bno_images\\b/i', $item['options'])) {
             return FALSE;
         }
         // in container
         if (is_object($anchor) && $anchor->has_option('no_images', FALSE)) {
             return FALSE;
         }
     }
     // surfer is not allowed to upload a file
     if (!Surfer::may_upload()) {
         return FALSE;
     }
     // surfer is an associate
     if (Surfer::is_associate()) {
         return TRUE;
     }
     // submissions have been disallowed
     if (isset($context['users_without_submission']) && $context['users_without_submission'] == 'Y') {
         return FALSE;
     }
     // only in articles
     if ($variant == 'article') {
         // surfer is entitled to change content
         if (Articles::allow_modification($item, $anchor)) {
             return TRUE;
         }
         // surfer is an editor, and the page is not private
         if (isset($item['active']) && $item['active'] != 'N' && Articles::is_assigned($item['id'])) {
             return TRUE;
         }
         if (is_object($anchor) && !$anchor->is_hidden() && $anchor->is_assigned()) {
             return TRUE;
         }
         // only in iles
     } elseif ($variant == 'file') {
         // surfer owns the anchor
         if (is_object($anchor) && $anchor->is_owned()) {
             return TRUE;
         }
         // only in sections
     } elseif ($variant == 'section') {
         // surfer is entitled to change content
         if (Sections::allow_modification($item, $anchor)) {
             return TRUE;
         }
         // only in user profiles
     } elseif ($variant == 'user') {
         // the item is anchored to the profile of this member
         if (Surfer::get_id() && is_object($anchor) && !strcmp($anchor->get_reference(), 'user:' . Surfer::get_id())) {
             return TRUE;
         }
         // should not happen...
         if (isset($item['id']) && Surfer::is($item['id'])) {
             return TRUE;
         }
     }
     // item has been locked
     if (isset($item['locked']) && $item['locked'] == 'Y') {
         return FALSE;
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:images.php

示例2: layout

 /**
  * list articles
  *
  * @param resource the SQL result
  * @return a string to be displayed
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // no hovering label
     $href_title = '';
     // we build an array for the skin::build_tabs() function
     $panels = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // panel content
         $text = '';
         // insert anchor prefix
         if (is_object($anchor)) {
             $text .= $anchor->get_prefix();
         }
         // the introduction text, if any
         if (is_object($overlay)) {
             $text .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
         } elseif (isset($item['introduction']) && trim($item['introduction'])) {
             $text .= Skin::build_block($item['introduction'], 'introduction');
         }
         // get text related to the overlay, if any
         if (is_object($overlay)) {
             $text .= $overlay->get_text('view', $item);
         }
         // filter description, if necessary
         if (is_object($overlay)) {
             $description = $overlay->get_text('description', $item);
         } else {
             $description = $item['description'];
         }
         // the beautified description, which is the actual page body
         if ($description) {
             // use adequate label
             if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
                 $text .= Skin::build_block($label, 'title');
             }
             // beautify the target page
             $text .= Skin::build_block($description, 'description', '', $item['options']);
         }
         // list files only to people able to change the page
         if (Articles::allow_modification($item, $anchor)) {
             $embedded = NULL;
         } else {
             $embedded = Codes::list_embedded($item['description']);
         }
         // build a complete box
         $box = array('bar' => array(), 'text' => '');
         // count the number of files in this article
         if ($count = Files::count_for_anchor('article:' . $item['id'], FALSE, $embedded)) {
             if ($count > 20) {
                 $box['bar'] += array('_count' => sprintf(i18n::ns('%d file', '%d files', $count), $count));
             }
             // list files by date (default) or by title (option files_by_title)
             $offset = ($zoom_index - 1) * FILES_PER_PAGE;
             if (Articles::has_option('files_by', $anchor, $item) == 'title') {
                 $items = Files::list_by_title_for_anchor('article:' . $item['id'], 0, 300, 'article:' . $item['id'], $embedded);
             } else {
                 $items = Files::list_by_date_for_anchor('article:' . $item['id'], 0, 300, 'article:' . $item['id'], $embedded);
             }
             // actually render the html
             if (is_array($items)) {
                 $box['text'] .= Skin::build_list($items, 'decorated');
             } elseif (is_string($items)) {
                 $box['text'] .= $items;
             }
             // the command to post a new file
             if (Files::allow_creation($item, $anchor, 'article')) {
                 Skin::define_img('FILES_UPLOAD_IMG', 'files/upload.gif');
                 $box['bar'] += array('files/edit.php?anchor=' . urlencode('article:' . $item['id']) => FILES_UPLOAD_IMG . i18n::s('Add a file'));
             }
         }
         // some files have been attached to this page
         if ($page == 1 && $count > 1) {
             // the command to download all files
             $link = 'files/fetch_all.php?anchor=' . urlencode('article:' . $item['id']);
             if ($count > 20) {
                 $label = i18n::s('Zip 20 first files');
             } else {
                 $label = i18n::s('Zip all files');
             }
             $box['bar'] += array($link => $label);
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:layout_articles_as_tabs.php

示例3: urlencode

// insert anchor suffix
if (is_object($anchor)) {
    $context['text'] .= $anchor->get_suffix();
}
//
// extra panel -- most content is cached, except commands specific to current surfer
//
// page tools
//
// post an image, if upload is allowed
if (Images::allow_creation($item, $anchor)) {
    Skin::define_img('IMAGES_ADD_IMG', 'images/add.gif');
    $context['page_tools'][] = Skin::build_link('images/edit.php?anchor=' . urlencode('article:' . $item['id']), IMAGES_ADD_IMG . i18n::s('Add an image'), 'basic', i18n::s('You can upload a camera shot, a drawing, or another image file.'));
}
// modify this page
if (Articles::allow_modification($item, $anchor)) {
    Skin::define_img('ARTICLES_EDIT_IMG', 'articles/edit.gif');
    if (!is_object($overlay) || !($label = $overlay->get_label('edit_command', 'articles'))) {
        $label = i18n::s('Edit this page');
    }
    $context['page_tools'][] = Skin::build_link(Articles::get_url($item['id'], 'edit'), ARTICLES_EDIT_IMG . $label, 'basic', i18n::s('Press [e] to edit'), FALSE, 'e');
}
// access previous versions, if any
if ($has_versions && Articles::is_owned($item, $anchor)) {
    Skin::define_img('ARTICLES_VERSIONS_IMG', 'articles/versions.gif');
    $context['page_tools'][] = Skin::build_link(Versions::get_url('article:' . $item['id'], 'list'), ARTICLES_VERSIONS_IMG . i18n::s('Versions'), 'basic', i18n::s('Restore a previous version if necessary'));
}
// publish this page
if (Articles::allow_publication($item, $anchor)) {
    if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE) {
        Skin::define_img('ARTICLES_PUBLISH_IMG', 'articles/publish.gif');
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:view_as_chat.php


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