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


PHP Articles::put方法代码示例

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


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

示例1: foreach

        if (is_array($value)) {
            foreach ($value as $sub_name => $sub_value) {
                $overlay->attributes[$name][$sub_name] = str_replace('\\', '\\\\', $sub_value);
            }
        } else {
            $overlay->attributes[$name] = str_replace('\\', '\\\\', $value);
        }
    }
    // update the record
    $item['overlay'] = serialize($overlay->attributes);
    // touch the related anchor
    if ($article = Anchors::get('article:' . $item['id'])) {
        $article->touch('vote', $item['id'], isset($_REQUEST['silent']) && $_REQUEST['silent'] == 'Y');
    }
    // update the database
    if (!Articles::put($item)) {
    } elseif ($next && !headers_sent()) {
        Safe::redirect($next);
        // ask for manual click
    } else {
        $context['text'] .= '<p>' . i18n::s('Thank you for your contribution') . "</p>\n";
        // link to the poll, depending on access rights
        $menu = array();
        if ($permitted) {
            $menu = array_merge($menu, array(Articles::get_permalink($item) => i18n::s('View poll results')));
        }
        // back to the front page
        $menu = array_merge($menu, array($context['url_to_root'] => i18n::s('Front page')));
        $context['text'] .= Skin::build_list($menu, 'menu_bar');
    }
}
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:vote.php

示例2: parse_tag_close

 function parse_tag_close($parser, $tag)
 {
     global $context;
     global $in_overlay, $overlay_class, $overlay_parameters;
     global $parsed_cdata, $parsed_item, $parsed_overlay, $parsing_report;
     // save gathered data if necessary
     switch ($tag) {
         case 'article':
             // end of article
             // transcode owner id
             $parsed_item['owner_id'] = Surfer::get_id();
             if (isset($parsed_item['owner_nick_name']) && ($user = Users::get($parsed_item['owner_nick_name']))) {
                 $parsed_item['owner_id'] = $user['id'];
             }
             // transcode creator id
             $parsed_item['create_id'] = Surfer::get_id();
             if (isset($parsed_item['create_nick_name']) && ($user = Users::get($parsed_item['create_nick_name']))) {
                 $parsed_item['create_id'] = $user['id'];
             }
             // transcode editor id
             $parsed_item['edit_id'] = Surfer::get_id();
             if (isset($parsed_item['edit_nick_name']) && ($user = Users::get($parsed_item['edit_nick_name']))) {
                 $parsed_item['edit_id'] = $user['id'];
             }
             // transcode publisher id
             $parsed_item['publish_id'] = Surfer::get_id();
             if (isset($parsed_item['publish_nick_name']) && ($user = Users::get($parsed_item['publish_nick_name']))) {
                 $parsed_item['publish_id'] = $user['id'];
             }
             // bind to given overlay
             $overlay = NULL;
             if ($overlay_class) {
                 $overlay = Overlay::bind($overlay_class . ' ' . $overlay_parameters);
             }
             // when the page has been overlaid
             if (is_object($overlay)) {
                 // update the overlay from content
                 foreach ($parsed_overlay as $label => $value) {
                     $overlay->attributes[$label] = $value;
                 }
                 // save content of the overlay in this item
                 $parsed_item['overlay'] = $overlay->save();
                 $parsed_item['overlay_id'] = $overlay->get_id();
             }
             // find anchor from handle
             if (isset($parsed_item['anchor_handle']) && ($reference = Sections::lookup($parsed_item['anchor_handle']))) {
                 $parsed_item['anchor'] = $reference;
             }
             // update an existing page
             if (isset($parsed_item['handle']) && ($item = Articles::get($parsed_item['handle']))) {
                 // transcode page id
                 $parsed_item['id'] = $item['id'];
                 // stop on error
                 if (!Articles::put($parsed_item) || is_object($overlay) && !$overlay->remember('update', $parsed_item, 'article:' . $item['id'])) {
                     Logger::error(sprintf('Unable to save article %s', $parsed_item['title'] . ' (' . $parsed_item['id'] . ')'));
                 }
                 // create a new page
             } else {
                 unset($parsed_item['id']);
                 // stop on error
                 if (!($parsed_item['id'] = Articles::post($parsed_item))) {
                     Logger::error(sprintf('Unable to save article %s', $parsed_item['title']));
                 } else {
                     // save overlay content
                     if (is_object($overlay)) {
                         $overlay->remember('insert', $parsed_item, 'article:' . $parsed_item['id']);
                     }
                 }
             }
             // report to surfer
             $parsing_report .= '<li>' . Skin::build_link(Articles::get_permalink($parsed_item), $parsed_item['title']) . "</li>\n";
             // ready for next item
             $overlay_class = NULL;
             $overlay_parameters = '';
             $parsed_overlay = array();
             $parsed_item = array();
             Safe::set_time_limit(30);
             break;
         case 'overlay':
             // end of overlay data
             $in_overlay = FALSE;
             break;
         case 'section':
             // end of section
             // transcode owner id
             $parsed_item['owner_id'] = Surfer::get_id();
             if (isset($parsed_item['owner_nick_name']) && ($user = Users::get($parsed_item['owner_nick_name']))) {
                 $parsed_item['owner_id'] = $user['id'];
             }
             // transcode creator id
             $parsed_item['create_id'] = Surfer::get_id();
             if (isset($parsed_item['create_nick_name']) && ($user = Users::get($parsed_item['create_nick_name']))) {
                 $parsed_item['create_id'] = $user['id'];
             }
             // transcode editor id
             $parsed_item['edit_id'] = Surfer::get_id();
             if (isset($parsed_item['edit_nick_name']) && ($user = Users::get($parsed_item['edit_nick_name']))) {
                 $parsed_item['edit_id'] = $user['id'];
             }
             // bind to given overlay
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:import.php

示例3: restore

 /**
  * restore a previous version of this article
  *
  * @see versions/restore.php
  *
  * @param array set of attributes to restore
  * @return TRUE on success, FALSE otherwise
  */
 function restore($item)
 {
     global $context;
     // restore this instance
     $this->item = $item;
     // save updated state
     return Articles::put($item);
 }
开发者ID:rair,项目名称:yacs,代码行数:16,代码来源:article.php

示例4: elseif

     include 'edit_as_' . $deputy . '.php';
     return;
     // update an existing page
 } elseif (isset($_REQUEST['id'])) {
     // remember the previous version
     if ($item['id'] && Versions::are_different($item, $_REQUEST)) {
         Versions::save($item, 'article:' . $item['id']);
     }
     // overlay has been inserted or updated
     if (isset($_REQUEST['overlay_type']) && $_REQUEST['overlay_type']) {
         $action = 'insert';
     } else {
         $action = 'update';
     }
     // stop on error
     if (!Articles::put($_REQUEST) || is_object($overlay) && !$overlay->remember($action, $_REQUEST, 'article:' . $_REQUEST['id'])) {
         $item = $_REQUEST;
         $with_form = TRUE;
         // else display the updated page
     } else {
         // do whatever is necessary on page update
         Articles::finalize_update($anchor, $_REQUEST, $overlay, isset($_REQUEST['silent']) && $_REQUEST['silent'] == 'Y', isset($_REQUEST['notify_watchers']) && $_REQUEST['notify_watchers'] == 'Y', isset($_REQUEST['notify_followers']) && $_REQUEST['notify_followers'] == 'Y');
         // cascade changes on access rights
         if ($_REQUEST['active'] != $item['active']) {
             Anchors::cascade('article:' . $item['id'], $_REQUEST['active']);
         }
         // the page has been modified
         $context['text'] .= '<p>' . i18n::s('The page has been successfully updated.') . '</p>';
         $recipients = Mailer::build_recipients('article:' . $item['id']);
         if ($render_overlaid) {
             echo 'post done';
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:edit.php


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