示例#1
0
function update_import_cell($base_feed, $owner, $key, $sheetid, $row, $col, $formula, $celledit)
{
    $updatedata = '<?xml version=\'1.0\' encoding=\'UTF-8\'?>
                        <entry xmlns="http://www.w3.org/2005/Atom" xmlns:docs="http://schemas.google.com/docs/2007" xmlns:gs="http://schemas.google.com/spreadsheets/2006">
                        <id>https://spreadsheets.google.com/feeds/cells/' . $key . '/' . $sheetid . '/private/full/R' . $row . 'C' . $col . '</id>
                        <link rel="edit" type="application/atom+xml"
                        href="' . $celledit . '"/>
                        <gs:cell row="' . $row . '" col="' . $col . '" inputValue="' . $formula . '"/>
                        </entry>';
    $params = array('xoauth_requestor_id' => $owner);
    return twolegged($base_feed, $params, 'PUT', $updatedata, '3.0');
}
$pagetitle = strip_tags($shortname . ': ' . name_folder($readwrite));
$update = null;
/*
   if (has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $course->id))) {
       $options = array('id'=>$course->id, 'wdir'=>'/'.$resource->reference.$subdir);
       $editfiles = print_single_button("$CFG->wwwroot/files/index.php", $options, get_string("editfiles"), 'get', '', true);
       $update = $editfiles.$update;
   }
* 
*/
//    $navigation = build_navigation($this->navlinks, $cm);
$navigation = build_navigation('Google docs folders');
print_header($pagetitle, $pagetitle, $navigation, "", "", true, $update, null);
print_heading($pagetitle);
// go get the docs if any
$docs = twolegged($base_feed, $params, 'GET');
$files = simplexml_load_string($docs->response);
/*
    $content = '';
    foreach($feed->entry as $file) {
        $content .= '- <a title="'.$file->title.' target="_blank"';
        foreach ($file->link as $link) {
            if ($link['rel'] == 'alternate') {
                $href = $link['href'];
                break;
            }
        }
        $content .= '" href="'. s($href) . '">' . substr($file->title,0,30).'</a> <br />';
//        $content .= '" href="'.(string) $file->link[1]['href'] . '">' . substr($file->title,0,30).'</a> <br />';
//        $content .= '" href="'.(string) $file->content['src'].'">'.substr($file->title,0,30).'</a> <br />';
    }
示例#3
0
 function get_sitepermissions()
 {
     $role = array();
     $response = twolegged($this->base_feed, $this->params, 'GET', null, '1.4');
     $permissions = $response->response;
     preg_match_all("/<gAcl:role[^>]+>/", $permissions, $roles);
     preg_match_all("/<gAcl:scope[^>]+>/", $permissions, $scopes);
     $rolestring = 'value=';
     $scopestring = 'value=';
     foreach ($scopes[0] as $key => $value) {
         $scope = substr($value, strpos($value, $scopestring) + strlen($scopestring) + 1, -3);
         if (!empty($scope)) {
             $role[$scope] = substr($roles[0][$key], strpos($roles[0][$key], $rolestring) + strlen($rolestring) + 1, -3);
         }
     }
     return $role;
 }
 public function get_file_list($search = '', $repo = null)
 {
     //		require_once('constants.php');
     global $CFG, $OUTPUT;
     $url = get_morsle_url($search);
     if (array_key_exists('path', $search)) {
         $path = $search['path'] . '/';
         unset($search['path']);
     } else {
         $path = null;
     }
     foreach ($search as $key => $param) {
         if ($key === 'q') {
             $param = urlencode($param);
         }
         $params[$key] = trim($param);
     }
     //       	$url .= '?' . implode_assoc('=', '&', $params);
     $content = twolegged($url, $params, 'GET');
     //       	$content = $this->get($url, $params, null);
     $xml = new SimpleXMLElement($content->response);
     $files = array();
     $repolink = "{$CFG->wwwroot}/repository/repository_ajax.php?action=list&p=";
     foreach ($xml->entry as $gdoc) {
         $docid = (string) $gdoc->children('http://schemas.google.com/g/2005')->resourceId;
         list($type, $docid) = explode(':', $docid);
         $title = (string) $gdoc->title;
         $source = '';
         // FIXME: We're making hard-coded choices about format here.
         // If the repo api can support it, we could let the user
         // chose.
         switch ($type) {
             case 'folder':
                 break;
             case 'document':
                 $temptitle = 'temp.doc';
                 break;
             case 'presentation':
                 $temptitle = 'temp.ppt';
                 break;
             case 'spreadsheet':
                 $temptitle = 'temp.xls';
                 break;
             case 'pdf':
                 $temptitle = 'temp.pdf';
                 break;
             default:
                 $temptitle = $gdoc->title;
         }
         $source = (string) get_href_noentry($gdoc, GDOC_ALT_REL);
         // TODO: get this thumbnail working with the display
         $iconlink = '<img src="' . (string) get_href_noentry($gdoc, GDOC_THUMB_REL) . '" />';
         if (!empty($source)) {
             if ($type == 'folder') {
                 echo null;
                 $files[] = array('title' => $title, 'url' => "{$gdoc->link[0]->attributes()->href}", 'source' => $source, 'date' => usertime(strtotime($gdoc->updated)), 'children' => array(), 'path' => base64_encode($docid . '|' . $path . $title), 'thumbnail' => (string) $OUTPUT->pix_url('f/folder-64'));
             } else {
                 $files[] = array('title' => $title, 'url' => $source, 'source' => $source, 'date' => usertime(strtotime($gdoc->updated)), 'thumbnail' => (string) $OUTPUT->pix_url(file_extension_icon($temptitle, 64)));
             }
         }
     }
     return $files;
 }