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


PHP Entry::set方法代码示例

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


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

示例1: save

    public function save()
    {
        $form = Form::load('logbook.views.AddBlogEntry');

        if($form->validate())
        {
            $auth = new Author();
            $auth->clause('user_id',Application::current()->user()->id());

            if($auth->id())
            {
                $item = new Entry();
                $item->parse();
                $item->set('author_id',$auth->id());

                if(!Application::param('entry_date'))
                    $item->set('entry_date',date('Y-m-d H:i:s'));

                $item->synch();
                Entry::setTagsAndSave($item,Application::param('entry_tags'));
                $group = new Group();
                $group->noForeign();
                $author_id = $item->get('author_id');
                $entry_id = $item->get('entry_id');
                
                if($groups = $group->fetch())
                {
                    foreach($groups as $group)
                    {
                        if(file_exists(Application::MANAGED_CODE.'lbk_default_access_'.$group->get('access_id')))
                        {
                            $data = file_get_contents(Application::MANAGED_CODE.'lbk_default_access_'.$group->get('access_id'));
                            $perms = unserialize($data);
                            ManageGroupAccess::setPermissionsOnEntryForGroup($author_id,$entry_id,$group->id(),$perms);
                        }
                    }
                }

                Application::setUrlParam('author_id',Application::param('author_id'));
                Application::setUrlParam('entry_id',Application::param('entry_id'));
                LogbookAccess::publishLookupTables();
                $this->redirectOnSave();
            }
            
            else
                die('You are not an author!');
        }
    }
开发者ID:k7n4n5t3w4rt,项目名称:SeeingSystem,代码行数:48,代码来源:add_blog_entry.class.php

示例2: updateEntry

function updateEntry($id)
{
    if (is_null($id)) {
        Functions::setResponse(400);
    }
    $data = Functions::getJSONData();
    try {
        $c = new Entry($id);
        foreach ($c->getFields() as $field) {
            $value = Functions::elt($data, $field['name']);
            if (is_null($value)) {
                Functions::setResponse(400);
            }
            $c->set($field['name'], $value);
        }
        $c->set('id', $id);
        $c->save();
        return true;
    } catch (RuntimeException $e) {
        Functions::setResponse(404);
    }
}
开发者ID:Babaritech,项目名称:babar2,代码行数:22,代码来源:entry.php

示例3: add

 /**
  * Given an Entry object, iterate over all of the fields in that object
  * an insert them into their relevant entry tables.
  *
  * @param Entry $entry
  *  An Entry object to insert into the database
  * @return boolean
  */
 public function add(Entry $entry)
 {
     $fields = $entry->get();
     Symphony::Database()->insert($fields, 'tbl_entries');
     if (!($entry_id = Symphony::Database()->getInsertID())) {
         return false;
     }
     foreach ($entry->getData() as $field_id => $field) {
         if (!is_array($field) || empty($field)) {
             continue;
         }
         Symphony::Database()->delete('tbl_entries_data_' . $field_id, " `entry_id` = '{$entry_id}'");
         $data = array('entry_id' => $entry_id);
         $fields = array();
         foreach ($field as $key => $value) {
             if (is_array($value)) {
                 foreach ($value as $ii => $v) {
                     $fields[$ii][$key] = $v;
                 }
             } else {
                 $fields[max(0, count($fields) - 1)][$key] = $value;
             }
         }
         for ($ii = 0; $ii < count($fields); $ii++) {
             $fields[$ii] = array_merge($data, $fields[$ii]);
         }
         Symphony::Database()->insert($fields, 'tbl_entries_data_' . $field_id);
     }
     $entry->set('id', $entry_id);
     return true;
 }
开发者ID:scottkf,项目名称:keepflippin--on-symphony,代码行数:39,代码来源:class.entrymanager.php

示例4: __ajaxImportRows

 /**
  * This function imports 10 rows of the CSV data
  * @return void
  */
 private function __ajaxImportRows()
 {
     $messageSuffix = '';
     $updated = array();
     $ignored = array();
     $csv = $this->__getCSV();
     if ($csv != false) {
         // Load the drivers:
         $drivers = $this->getDrivers();
         // Default parameters:
         $currentRow = intval($_POST['row']);
         $sectionID = $_POST['section-id'];
         $uniqueAction = $_POST['unique-action'];
         $uniqueField = $_POST['unique-field'];
         $fieldIDs = explode(',', $_POST['field-ids']);
         $entryID = null;
         // Load the fieldmanager:
         $fm = new FieldManager($this);
         // Load the entrymanager:
         $em = new EntryManager($this);
         // Load the CSV data of the specific rows:
         $csvTitles = $csv->titles;
         $csvData = $csv->data;
         for ($i = $currentRow * 10; $i < ($currentRow + 1) * 10; $i++) {
             // Start by creating a new entry:
             $entry = new Entry($this);
             $entry->set('section_id', $sectionID);
             // Ignore this entry?
             $ignore = false;
             // Import this row:
             $row = $csvData[$i];
             if ($row != false) {
                 // If a unique field is used, make sure there is a field selected for this:
                 if ($uniqueField != 'no' && $fieldIDs[$uniqueField] == 0) {
                     die(__('[ERROR: No field id sent for: "' . $csvTitles[$uniqueField] . '"]'));
                 }
                 // Unique action:
                 if ($uniqueField != 'no') {
                     // Check if there is an entry with this value:
                     $field = $fm->fetch($fieldIDs[$uniqueField]);
                     $type = $field->get('type');
                     if (isset($drivers[$type])) {
                         $drivers[$type]->setField($field);
                         $entryID = $drivers[$type]->scanDatabase($row[$csvTitles[$uniqueField]]);
                     } else {
                         $drivers['default']->setField($field);
                         $entryID = $drivers['default']->scanDatabase($row[$csvTitles[$uniqueField]]);
                     }
                     if ($entryID != false) {
                         // Update? Ignore? Add new?
                         switch ($uniqueAction) {
                             case 'update':
                                 $a = $em->fetch($entryID);
                                 $entry = $a[0];
                                 $updated[] = $entryID;
                                 break;
                             case 'ignore':
                                 $ignored[] = $entryID;
                                 $ignore = true;
                                 break;
                         }
                     }
                 }
                 if (!$ignore) {
                     // Do the actual importing:
                     $j = 0;
                     foreach ($row as $value) {
                         // When no unique field is found, treat it like a new entry
                         // Otherwise, stop processing to safe CPU power.
                         $fieldID = intval($fieldIDs[$j]);
                         // If $fieldID = 0, then `Don't use` is selected as field. So don't use it! :-P
                         if ($fieldID != 0) {
                             $field = $fm->fetch($fieldID);
                             // Get the corresponding field-type:
                             $type = $field->get('type');
                             if (isset($drivers[$type])) {
                                 $drivers[$type]->setField($field);
                                 $data = $drivers[$type]->import($value, $entryID);
                             } else {
                                 $drivers['default']->setField($field);
                                 $data = $drivers['default']->import($value, $entryID);
                             }
                             // Set the data:
                             if ($data != false) {
                                 $entry->setData($fieldID, $data);
                             }
                         }
                         $j++;
                     }
                     // Store the entry:
                     $entry->commit();
                 }
             }
         }
     } else {
         die(__('[ERROR: CSV Data not found!]'));
//.........这里部分代码省略.........
开发者ID:michael-e,项目名称:importcsv,代码行数:101,代码来源:content.index.php


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