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


PHP General::formatFilesize方法代码示例

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


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

示例1: buildContent

 public function buildContent($wrapper)
 {
     $this->addStylesheetToHead(URL . '/extensions/profiledevkit/assets/devkit.css', 'screen', 9126343);
     $table = new XMLElement('table');
     $table->setAttribute('id', $this->_view);
     if ($this->_view == 'render-statistics') {
         $xml_generation = $this->_profiler->retrieveByMessage('XML Generation');
         $xsl_transformation = $this->_profiler->retrieveByMessage('XSLT Transformation');
         $event_total = 0;
         foreach ($this->_records['events'] as $data) {
             $event_total += $data[1];
         }
         $ds_total = 0;
         foreach ($this->_records['data-sources'] as $data) {
             $ds_total += $data[1];
         }
         $this->_records = array(array(__('Total Database Queries'), $this->_dbstats['queries'], NULL, NULL, false), array(__('Slow Queries (> 0.09s)'), count($this->_dbstats['slow-queries']), NULL, NULL, false), array(__('Total Time Spent on Queries'), $this->_dbstats['total-query-time']), array(__('Time Triggering All Events'), $event_total), array(__('Time Running All Data Sources'), $ds_total), array(__('XML Generation Function'), $xml_generation[1]), array(__('XSLT Generation'), $xsl_transformation[1]), array(__('Output Creation Time'), $this->_profiler->retrieveTotalRunningTime()), array(__('Total Memory Usage'), General::formatFilesize($this->_profiler->retrieveTotalMemoryUsage()), NULL, NULL, false));
         foreach ($this->_records as $data) {
             $row = new XMLElement('tr');
             $row->appendChild(new XMLElement('th', $data[0]));
             $row->appendChild(new XMLElement('td', $data[1] . (isset($data[4]) && $data[4] == false ? '' : ' s')));
             $table->appendChild($row);
         }
     } elseif ($this->_view == 'memory-usage') {
         $items = $this->_profiler->retrieve();
         $base = $items[0][5];
         $total = 0;
         $last = 0;
         foreach ($items as $index => $item) {
             $row = new XMLElement('tr');
             $row->appendChild(new XMLElement('th', $item[0]));
             $row->appendChild(new XMLElement('td', General::formatFilesize(max(0, $item[5] - $base - $last))));
             $table->appendChild($row);
             $last = $item[5] - $base;
         }
     } else {
         if ($this->_records = $this->_records[$this->_view]) {
             $ds_total = 0;
             foreach ($this->_records as $data) {
                 $row = new XMLElement('tr');
                 $row->appendChild(new XMLElement('th', $data[0]));
                 if ($this->_view == 'general') {
                     $row->appendChild(new XMLElement('td', $data[1] . ' s'));
                 } else {
                     if ($this->_view == 'slow-queries') {
                         $row->appendChild(new XMLElement('td', $data[1] . (isset($data[4]) && $data[4] == false ? '' : ' s')));
                     } else {
                         $row->appendChild(new XMLElement('td', $data[1] . ' s from ' . $data[4] . ' ' . ($data[4] == 1 ? 'query' : 'queries')));
                     }
                 }
                 $ds_total += $data[1];
                 $table->appendChild($row);
             }
         }
     }
     $wrapper->appendChild($table);
 }
开发者ID:pointybeard,项目名称:profiledevkit,代码行数:57,代码来源:content.profile.php

示例2: appendFormattedElement

 public function appendFormattedElement(&$wrapper, $data, $encode = false)
 {
     if (!is_array($data) || empty($data)) {
         return;
     }
     if (!is_array($data['file'])) {
         if (!$data['file']) {
             return;
         }
         $data = array('file' => array($data['file']));
     }
     $item = new XMLElement($this->get('element_name'));
     $path = DOCROOT;
     $item->setAttributeArray(array('path' => str_replace(WORKSPACE, '', $path)));
     foreach ($data['file'] as $index => $file) {
         $item->appendChild(new XMLElement('item', General::sanitize($file), array('size' => General::formatFilesize(filesize($path . $file)))));
     }
     $wrapper->appendChild($item);
 }
开发者ID:symphonists,项目名称:uploadselectboxfield,代码行数:19,代码来源:field.uploadselectbox.php

示例3: appendFormattedElement

 public function appendFormattedElement(XMLElement &$wrapper, $data, $encode = false, $mode = null, $entry_id = null)
 {
     // It is possible an array of null data will be passed in. Check for this.
     if (!is_array($data) || !isset($data['file']) || is_null($data['file'])) {
         return;
     }
     $item = new XMLElement($this->get('element_name'));
     $url = $this->getUrl($data['file']);
     $filesize = $data['size'];
     $item->setAttributeArray(array('size' => !is_null($filesize) ? General::formatFilesize($filesize) : 'unknown', 'bytes' => !is_null($filesize) ? $filesize : 'unknown', 'url' => $url, 'type' => $data['mimetype']));
     $item->appendChild(new XMLElement('filename', General::sanitize(basename($data['file']))));
     // These are 'deprecated', should use the attributes
     $item->appendChild(new XMLElement('size', $data['size']));
     $item->appendChild(new XMLElement('mimetype', $data['mimetype']));
     $m = unserialize($data['meta']);
     if (is_array($m) && !empty($m)) {
         $item->appendChild(new XMLElement('meta', NULL, $m));
     }
     $wrapper->appendChild($item);
 }
开发者ID:TheJester12,项目名称:s3upload_field,代码行数:20,代码来源:field.s3upload.php

示例4: grab


//.........这里部分代码省略.........
                         $author = new XMLElement("author");
                         $author_fields = array("first-name" => $author_rec['firstname'], "last-name" => $author_rec['lastname'], "email" => $author_rec['email'], "username" => $author_rec['username']);
                         $this->__addChildFieldsToXML($author_fields, $author, "author");
                         $entry->addChild($author);
                         ##Custom Fields
                         $fields = $row['fields'];
                         if (is_array($fields) && !empty($fields)) {
                             $customFields = new XMLElement("fields");
                             foreach ($fields as $f) {
                                 if (@in_array($f['field_handle'], $this->_dsFilterXMLFIELDS)) {
                                     $newField = new XMLElement($f['field_handle']);
                                     if ($f['type'] == 'list' || $f['type'] == 'multiselect') {
                                         foreach ($f['value_raw'] as $val) {
                                             $item = new XMLElement("item", $val);
                                             $item->setAttribute("handle", Lang::createHandle($val, $this->_parent->getConfigVar('handle_length', 'admin')));
                                             $newField->addChild($item);
                                         }
                                     } elseif ($f['type'] == 'foreign') {
                                         $sid = $f['foreign_section'];
                                         $section_handle = $this->_db->fetchVar('handle', 0, "SELECT `handle` FROM `tbl_sections` WHERE `id` = '{$sid} ' LIMIT 1");
                                         $newField->setAttribute("handle", $f['handle']);
                                         $newField->setAttribute("type", 'foreign');
                                         $newField->setAttribute("section-id", $sid);
                                         $newField->setAttribute("section-handle", $sid);
                                         if (!is_array($f['value_raw'])) {
                                             $f['value_raw'] = array($f['value_raw']);
                                         }
                                         foreach ($f['value_raw'] as $h) {
                                             $entry_id = $entryManager->fetchEntryIDFromPrimaryFieldHandle($sid, $h);
                                             $e = $entryManager->fetchEntriesByID($entry_id, false, true);
                                             $item = new XMLElement("item", trim($e['fields'][$e['primary_field']]['value']));
                                             $item->setAttribute("entry-id", $entry_id[0]);
                                             $item->setAttribute("entry-handle", $e['fields'][$e['primary_field']]['handle']);
                                             $newField->addChild($item);
                                         }
                                     } elseif ($f['type'] == 'upload') {
                                         foreach ($f['value_raw'] as $val) {
                                             $item = new XMLElement("item");
                                             $item->addChild(new XMLElement("path", trim($val['path'], '/')));
                                             $item->addChild(new XMLElement("type", $val['type']));
                                             $item->addChild(new XMLElement("size", General::formatFilesize($val['size'])));
                                             $newField->addChild($item);
                                         }
                                     } elseif ($f['type'] == 'checkbox') {
                                         $newField->setValue($f['value_raw']);
                                     } elseif ($f['type'] == 'select') {
                                         $newField->setValue($f['value_raw']);
                                         $newField->setAttribute("handle", $f['handle']);
                                     } else {
                                         $key = 'value';
                                         if ($f['format'] != 1) {
                                             $key = 'value_raw';
                                         }
                                         $f[$key] = trim($f[$key]);
                                         $value = $f[$key];
                                         if ($this->_dsFilterENCODE == "yes") {
                                             $value = trim(General::sanitize($f[$key]));
                                         }
                                         if ($f['type'] == 'textarea') {
                                             $newField->setValue($value);
                                             $newField->setAttribute("word-count", General::countWords(strip_tags($f['value'])));
                                         } elseif ($f['type'] == 'input' && $f['field_id'] != $row['primary_field']) {
                                             $newField->setAttribute("handle", $f['handle']);
                                             $newField->setValue($value);
                                         }
                                     }
                                     $customFields->addChild($newField);
                                 }
                             }
                             $entry->addChild($customFields);
                         }
                         ##Comments
                         $commenting = $this->_db->fetchVar('commenting', 0, "SELECT `commenting` FROM `tbl_sections` WHERE `id` = '{$section_id}' LIMIT 1");
                         if ($commenting == 'on') {
                             $comments = new XMLElement("comments");
                             $sql = "SELECT  count(*) as `count` " . "FROM `tbl_comments` " . "WHERE `entry_id` = '" . $row['id'] . "'";
                             $comment_count = max(0, @intval($this->_db->fetchVar("count", 0, $sql . " AND `spam` = 'no'")));
                             $spam_count = max(0, @intval($this->_db->fetchVar("count", 0, $sql . " AND `spam` = 'yes'")));
                             $comments->setAttribute("count", "" . $comment_count . "");
                             $comments->setAttribute("spam", "" . $spam_count . "");
                             $entry->addChild($comments);
                         }
                         $xDay->addChild($entry);
                     }
                     $xMonth->addChild($xDay);
                 }
                 $xYear->addChild($xMonth);
             }
             $xml->addChild($xYear);
         }
     }
     ##------------------------------
     ##Write To Cache
     if ($param['caching']) {
         $result = $xml->generate($param['indent'], $param['indent-depth']);
         $this->write_to_cache($hash_id, $result, $this->_cache_sections);
         return $result;
     }
     return $xml;
 }
开发者ID:symphonycms,项目名称:symphony-1.7,代码行数:101,代码来源:data.archive_entry_list.php

示例5: checkPostFieldData

 function checkPostFieldData($data, &$message, $entry_id = NULL)
 {
     /*
     	UPLOAD_ERR_OK
     	Value: 0; There is no error, the file uploaded with success.
     
     	UPLOAD_ERR_INI_SIZE
     	Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.
     
     	UPLOAD_ERR_FORM_SIZE
     	Value: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
     
     	UPLOAD_ERR_PARTIAL
     	Value: 3; The uploaded file was only partially uploaded.
     
     	UPLOAD_ERR_NO_FILE
     	Value: 4; No file was uploaded.
     
     	UPLOAD_ERR_NO_TMP_DIR
     	Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.
     
     	UPLOAD_ERR_CANT_WRITE
     	Value: 7; Failed to write file to disk. Introduced in PHP 5.1.0.
     
     	UPLOAD_ERR_EXTENSION
     	Value: 8; File upload stopped by extension. Introduced in PHP 5.2.0.
     */
     //	Array
     //	(
     //	    [name] => filename.pdf
     //	    [type] => application/pdf
     //	    [tmp_name] => /tmp/php/phpYtdlCl
     //	    [error] => 0
     //	    [size] => 16214
     //	)
     $message = NULL;
     if (empty($data) || $data['error'] == UPLOAD_ERR_NO_FILE) {
         if ($this->get('required') == 'yes') {
             $message = __("'%s' is a required field.", $this->get('label'));
             return self::__MISSING_FIELDS__;
         }
         return self::__OK__;
     }
     ## Its not an array, so just retain the current data and return
     if (!is_array($data)) {
         return self::__OK__;
     }
     if (!is_writable(DOCROOT . $this->get('destination') . '/')) {
         $message = __('Destination folder, <code>%s</code>, is not writable. Please check permissions.', array($this->get('destination')));
         return self::__ERROR__;
     }
     if ($data['error'] != UPLOAD_ERR_NO_FILE && $data['error'] != UPLOAD_ERR_OK) {
         switch ($data['error']) {
             case UPLOAD_ERR_INI_SIZE:
                 $message = __('File chosen in "%1$s" exceeds the maximum allowed upload size of %2$s specified by your host.', array($this->get('label'), is_numeric(ini_get('upload_max_filesize')) ? General::formatFilesize(ini_get('upload_max_filesize')) : ini_get('upload_max_filesize')));
                 break;
             case UPLOAD_ERR_FORM_SIZE:
                 $message = __('File chosen in "%1$s" exceeds the maximum allowed upload size of %2$s, specified by Symphony.', array($this->get('label'), General::formatFilesize($this->_engine->Configuration->get('max_upload_size', 'admin'))));
                 break;
             case UPLOAD_ERR_PARTIAL:
                 $message = __("File chosen in '%s' was only partially uploaded due to an error.", array($this->get('label')));
                 break;
             case UPLOAD_ERR_NO_TMP_DIR:
                 $message = __("File chosen in '%s' was only partially uploaded due to an error.", array($this->get('label')));
                 break;
             case UPLOAD_ERR_CANT_WRITE:
                 $message = __("Uploading '%s' failed. Could not write temporary file to disk.", array($this->get('label')));
                 break;
             case UPLOAD_ERR_EXTENSION:
                 $message = __("Uploading '%s' failed. File upload stopped by extension.", array($this->get('label')));
                 break;
         }
         return self::__ERROR_CUSTOM__;
     }
     ## Sanitize the filename
     $data['name'] = Lang::createFilename($data['name']);
     if ($this->get('validator') != NULL) {
         $rule = $this->get('validator');
         if (!General::validateString($data['name'], $rule)) {
             $message = __("File chosen in '%s' does not match allowable file types for that field.", array($this->get('label')));
             return self::__INVALID_FIELDS__;
         }
     }
     $abs_path = DOCROOT . '/' . trim($this->get('destination'), '/');
     $new_file = $abs_path . '/' . $data['name'];
     $existing_file = NULL;
     if ($entry_id) {
         $row = $this->Database->fetchRow(0, "SELECT * FROM `tbl_entries_data_" . $this->get('id') . "` WHERE `entry_id` = '{$entry_id}' LIMIT 1");
         $existing_file = $abs_path . '/' . trim($row['file'], '/');
     }
     if ($existing_file != $new_file && file_exists($new_file)) {
         $message = __('A file with the name %1$s already exists in %2$s. Please rename the file first, or choose another.', array($data['name'], $this->get('destination')));
         return self::__INVALID_FIELDS__;
     }
     return self::__OK__;
 }
开发者ID:bauhouse,项目名称:sym-fluid960gs,代码行数:96,代码来源:field.upload.php

示例6: appendFormattedElement

 public function appendFormattedElement(XMLElement &$wrapper, $data, $encode = false, $mode = null, $entry_id = null)
 {
     // It is possible an array of null data will be passed in. Check for this.
     if (!is_array($data) || !isset($data['file']) || is_null($data['file'])) {
         return;
     }
     $file = $this->getFilePath($data['file']);
     $filesize = file_exists($file) && is_readable($file) ? filesize($file) : null;
     $item = new XMLElement($this->get('element_name'));
     $item->setAttributeArray(array('size' => !is_null($filesize) ? General::formatFilesize($filesize) : 'unknown', 'bytes' => !is_null($filesize) ? $filesize : 'unknown', 'path' => General::sanitize(str_replace(WORKSPACE, null, dirname($file))), 'type' => $data['mimetype']));
     $item->appendChild(new XMLElement('filename', General::sanitize(basename($file))));
     $m = unserialize($data['meta']);
     if (is_array($m) && !empty($m)) {
         $item->appendChild(new XMLElement('meta', null, $m));
     }
     $wrapper->appendChild($item);
 }
开发者ID:valery,项目名称:symphony-2,代码行数:17,代码来源:field.upload.php

示例7: frontendOutputPostGenerate

 public function frontendOutputPostGenerate($context)
 {
     // don't output anything for unauthenticated users
     if (!Frontend::instance()->isLoggedIn()) {
         return;
     }
     require_once EXTENSIONS . '/firebug_profiler/lib/FirePHPCore/FirePHP.class.php';
     $firephp = FirePHP::getInstance(true);
     $events = Frontend::instance()->Profiler->retrieveGroup('Events');
     $datasources = Frontend::instance()->Profiler->retrieveGroup('Datasource');
     $xml_generation = Frontend::instance()->Profiler->retrieveByMessage('XML Generation');
     $dbstats = Frontend::instance()->Database->getStatistics();
     // Profile group
     $firephp->group('Profile', array('Collapsed' => false));
     $table = array();
     $table[] = array('', '');
     foreach (Frontend::instance()->Profiler->retrieveGroup('General') as $profile) {
         $table[] = array($profile[0], $profile[1] . 's');
     }
     $firephp->table('Page Building', $table);
     $event_total = 0;
     foreach ($events as $r) {
         $event_total += $r[1];
     }
     $ds_total = 0;
     foreach ($datasources as $r) {
         $ds_total += $r[1];
     }
     $table = array();
     $table[] = array('', '');
     $table[] = array(__('Total Database Queries'), $dbstats['queries']);
     if (count($dbstats['slow-queries']) > 0) {
         $table[] = array(__('Slow Queries (> 0.09s)'), count($dbstats['slow-queries']) . 's');
     }
     $table[] = array(__('Total Time Spent on Queries'), $dbstats['total-query-time'] . 's');
     $table[] = array(__('Time Triggering All Events'), $event_total) . 's';
     $table[] = array(__('Time Running All Data Sources'), $ds_total . 's');
     $table[] = array(__('XML Generation Function'), $xml_generation[1] . 's');
     // $table[] = array(__('XSLT Generation'), $xsl_transformation[1]); not available for this delegate
     $total = Frontend::instance()->Profiler->retrieveTotalRunningTime();
     $table[] = array(__('Output Creation Time'), $total);
     $table[] = array(__('Total Memory Usage'), General::formatFilesize(Frontend::instance()->Profiler->retrieveTotalMemoryUsage()));
     $firephp->table('Page Output (' . $total . 's, ' . $dbstats['queries'] . ' queries, ' . General::formatFilesize(Frontend::instance()->Profiler->retrieveTotalMemoryUsage()) . ')', $table);
     if (count($datasources) > 0) {
         $table = array();
         $table[] = array('Data Source', 'Time', 'Queries');
         foreach ($datasources as $profile) {
             $table[] = array($profile[0], $profile[1] . 's', $profile[4]);
         }
         $firephp->table('Data Sources', $table);
     }
     if (count($events) > 0) {
         $table = array();
         $table[] = array('Event', 'Time', 'Queries');
         foreach ($events as $profile) {
             $table[] = array($profile[0], $profile[1] . 's', $profile[4]);
         }
         $firephp->table('Events', $table);
     }
     $firephp->groupEnd();
     // Debug group
     $xml = simplexml_load_string($this->xml);
     $firephp->group('Debug', array('Collapsed' => false));
     if ($this->_Parent->Configuration->get('enabled', 'firebug_profiler') == 'yes') {
         $table = array();
         $table[] = array('Event', 'XML');
         $xml_events = $xml->xpath('/data/events/*');
         if (count($xml_events) > 0) {
             foreach ($xml_events as $event) {
                 $table[] = array($event->getName(), $event->asXML());
             }
             $firephp->table('Events (' . count($xml_events) . ')', $table);
         }
         $table = array();
         $table[] = array('Data Source', 'Entries', 'XML');
         $xml_datasources = $xml->xpath('/data/*[name() != "events"]');
         if (count($xml_datasources) > 0) {
             foreach ($xml_datasources as $ds) {
                 $entries = $ds->xpath('entry[@id]');
                 $table[] = array($ds->getName(), count($entries), $ds->asXML());
             }
             $firephp->table('Data Sources (' . count($xml_datasources) . ')', $table);
         }
     }
     $param_table = array();
     $param_table[] = array('Parameter', 'Value');
     foreach ($this->params as $name => $value) {
         if ($name == 'root') {
             continue;
         }
         $param_table[] = array('$' . trim($name), $value == null ? '' : $value);
     }
     $firephp->table('Page Parameters', $param_table);
     $firephp->groupEnd();
 }
开发者ID:symphonists,项目名称:firebug_profiler,代码行数:95,代码来源:extension.driver.php

示例8: checkPostFieldData

 function checkPostFieldData($data, &$message, $entry_id = NULL)
 {
     /*
     	UPLOAD_ERR_OK
     	Value: 0; There is no error, the file uploaded with success.
     
     	UPLOAD_ERR_INI_SIZE
     	Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.
     
     	UPLOAD_ERR_FORM_SIZE
     	Value: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
     
     	UPLOAD_ERR_PARTIAL
     	Value: 3; The uploaded file was only partially uploaded.
     
     	UPLOAD_ERR_NO_FILE
     	Value: 4; No file was uploaded.
     
     	UPLOAD_ERR_NO_TMP_DIR
     	Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.
     
     	UPLOAD_ERR_CANT_WRITE
     	Value: 7; Failed to write file to disk. Introduced in PHP 5.1.0.
     
     	UPLOAD_ERR_EXTENSION
     	Value: 8; File upload stopped by extension. Introduced in PHP 5.2.0.
     
     	Array
     	(
     		[name] => filename.pdf
     		[type] => application/pdf
     		[tmp_name] => /tmp/php/phpYtdlCl
     		[error] => 0
     		[size] => 16214
     	)
     */
     $message = NULL;
     if (empty($data) || $data['error'] == UPLOAD_ERR_NO_FILE) {
         if ($this->get('required') == 'yes') {
             $message = __("'%s' is a required field.", array($this->get('label')));
             return self::__MISSING_FIELDS__;
         }
         return self::__OK__;
     }
     // Its not an array, so just retain the current data and return
     if (!is_array($data)) {
         // Ensure the file exists in the `WORKSPACE` directory
         // @link http://symphony-cms.com/discuss/issues/view/610/
         $file = WORKSPACE . preg_replace(array('%/+%', '%(^|/)../%'), '/', $data);
         if (!file_exists($file) || !is_readable($file)) {
             $message = __('The file uploaded is no longer available. Please check that it exists, and is readable.');
             return self::__INVALID_FIELDS__;
         }
         // Ensure that the file still matches the validator and hasn't
         // changed since it was uploaded.
         if ($this->get('validator') != NULL) {
             $rule = $this->get('validator');
             if (!General::validateString($file, $rule)) {
                 $message = __("File chosen in '%s' does not match allowable file types for that field.", array($this->get('label')));
                 return self::__INVALID_FIELDS__;
             }
         }
         return self::__OK__;
     }
     if (!is_dir(DOCROOT . $this->get('destination') . '/')) {
         $message = __('The destination directory, <code>%s</code>, does not exist.', array($this->get('destination')));
         return self::__ERROR__;
     } elseif (!is_writable(DOCROOT . $this->get('destination') . '/')) {
         $message = __('Destination folder, <code>%s</code>, is not writable. Please check permissions.', array($this->get('destination')));
         return self::__ERROR__;
     }
     if ($data['error'] != UPLOAD_ERR_NO_FILE && $data['error'] != UPLOAD_ERR_OK) {
         switch ($data['error']) {
             case UPLOAD_ERR_INI_SIZE:
                 $message = __('File chosen in "%1$s" exceeds the maximum allowed upload size of %2$s specified by your host.', array($this->get('label'), is_numeric(ini_get('upload_max_filesize')) ? General::formatFilesize(ini_get('upload_max_filesize')) : ini_get('upload_max_filesize')));
                 break;
             case UPLOAD_ERR_FORM_SIZE:
                 $message = __('File chosen in "%1$s" exceeds the maximum allowed upload size of %2$s, specified by Symphony.', array($this->get('label'), General::formatFilesize(Symphony::Configuration()->get('max_upload_size', 'admin'))));
                 break;
             case UPLOAD_ERR_PARTIAL:
             case UPLOAD_ERR_NO_TMP_DIR:
                 $message = __("File chosen in '%s' was only partially uploaded due to an error.", array($this->get('label')));
                 break;
             case UPLOAD_ERR_CANT_WRITE:
                 $message = __("Uploading '%s' failed. Could not write temporary file to disk.", array($this->get('label')));
                 break;
             case UPLOAD_ERR_EXTENSION:
                 $message = __("Uploading '%s' failed. File upload stopped by extension.", array($this->get('label')));
                 break;
         }
         return self::__ERROR_CUSTOM__;
     }
     // Sanitize the filename
     $data['name'] = Lang::createFilename($data['name']);
     if ($this->get('validator') != NULL) {
         $rule = $this->get('validator');
         if (!General::validateString($data['name'], $rule)) {
             $message = __("File chosen in '%s' does not match allowable file types for that field.", array($this->get('label')));
             return self::__INVALID_FIELDS__;
         }
//.........这里部分代码省略.........
开发者ID:scottkf,项目名称:keepflippin--on-symphony,代码行数:101,代码来源:field.upload.php

示例9: appendFormattedElement

 public function appendFormattedElement(SymphonyDOMElement $wrapper, $data, $encode = false, $mode = null, Entry $entry = null)
 {
     if (!$this->sanitizeDataArray($data)) {
         return null;
     }
     $document = $wrapper->ownerDocument;
     $meta = unserialize($data->meta);
     if (!is_array($meta)) {
         $meta = array();
     }
     $meta['size'] = General::formatFilesize($data->size);
     $meta['type'] = $data->type;
     ksort($meta);
     $field = $document->createElement($this->{'element-name'});
     $field->appendChild($document->createElement('file', $data->name, array('path' => trim($data->path, '/'), 'name' => $data->file)));
     $element = $document->createElement('meta');
     foreach ($meta as $key => $value) {
         if ($key == 'creation' or $key == 'type') {
             $element->setAttribute($key, $value);
         } else {
             if ($key == 'size') {
                 $bits = explode(' ', $value);
                 if (count($bits) != 2) {
                     continue;
                 }
                 $element->appendChild($document->createElement('size', $bits[0], array('unit' => $bits[1])));
             } else {
                 if (is_array($value)) {
                     $element->appendChild($document->createElement($key, null, $value));
                 } else {
                     $element->appendChild($document->createElement($key, (string) $value));
                 }
             }
         }
     }
     $field->appendChild($element);
     ###
     # Delegate: UploadField_AppendFormattedElement
     # Description: Allow other extensions to add media previews.
     Extension::notify('UploadField_AppendFormattedElement', '/publish/', array('data' => $data, 'entry' => $entry, 'field' => $this, 'wrapper' => $field));
     $wrapper->appendChild($field);
 }
开发者ID:pointybeard,项目名称:symphony-3,代码行数:42,代码来源:field.upload.php

示例10: buildContent

 public function buildContent(XMLElement $wrapper)
 {
     $this->addStylesheetToHead(URL . '/extensions/profiledevkit/assets/devkit.css', 'screen', 9126343);
     $table = new XMLElement('table');
     $table->setAttribute('id', $this->_view);
     if ($this->_view == 'render-statistics') {
         $xml_generation = Symphony::Profiler()->retrieveByMessage('XML Generation');
         $xsl_transformation = Symphony::Profiler()->retrieveByMessage('XSLT Transformation');
         $event_total = 0;
         foreach ($this->_records['events'] as $data) {
             $event_total += $data[1];
         }
         $ds_total = 0;
         foreach ($this->_records['data-sources'] as $data) {
             $ds_total += $data[1];
         }
         $this->_records = array(array(__('Total Database Queries'), $this->_dbstats['queries'], NULL, NULL, false), array(__('Slow Queries (> 0.09s)'), (string) count($this->_dbstats['slow-queries']), NULL, NULL, false), array(__('Total Time Spent on Queries'), $this->_dbstats['total-query-time']), array(__('Time Triggering All Events'), $event_total), array(__('Time Running All Data Sources'), $ds_total), array(__('XML Generation'), $xml_generation[1]), array(__('XSLT Transformation'), $xsl_transformation[1]), array(__('Output Creation Time'), Symphony::Profiler()->retrieveTotalRunningTime()), array(__('Total Memory Usage'), General::formatFilesize(Symphony::Profiler()->retrieveTotalMemoryUsage()), NULL, NULL, false));
         foreach ($this->_records as $data) {
             if (!isset($data[4]) || $data[4] !== false) {
                 $data[1] = number_format($data[1], 4) . ' s';
             }
             $row = new XMLElement('tr');
             $row->appendChild(new XMLElement('th', $data[0]));
             $row->appendChild(new XMLElement('td', $data[1]));
             $table->appendChild($row);
         }
     } else {
         if ($this->_view == 'memory-usage') {
             $items = Symphony::Profiler()->retrieve();
             $base = $items[0][5];
             $total = 0;
             $last = 0;
             foreach ($items as $index => $item) {
                 // Build row display name
                 if (in_array($item[3], array('Datasource', 'Event'))) {
                     $display_value = $item[3] . ': ' . $item[0];
                 } else {
                     if ($item[3] == 'Delegate') {
                         $display_value = str_replace('|', ': ', $item[0]);
                     } else {
                         $display_value = $item[0];
                     }
                 }
                 $row = new XMLElement('tr');
                 $row->appendChild(new XMLElement('th', $display_value));
                 $row->appendChild(new XMLElement('td', General::formatFilesize(max(0, $item[5] - $base - $last))));
                 $table->appendChild($row);
                 $last = $item[5] - $base;
             }
         } else {
             if ($this->_view == 'database-queries') {
                 $debug = Symphony::Database()->debug();
                 if (count($debug) > 0) {
                     $i = 1;
                     foreach ($debug as $query) {
                         $row = new XMLElement('tr');
                         $row->appendChild(new XMLElement('th', $i));
                         $row->appendChild(new XMLElement('td', number_format($query['execution_time'], 4)));
                         $row->appendChild(new XMLElement('td', $query['query']));
                         $table->appendChild($row);
                         $i++;
                     }
                 }
             } else {
                 if ($this->_view == 'delegates') {
                     $delegates = array();
                     $debug = Symphony::Database()->debug();
                     // Build an array of delegate => extensions
                     foreach ($this->_records['delegates'] as $data) {
                         $parts = explode('|', $data[0]);
                         $data[0] = $parts[1];
                         $delegates[$parts[0]][] = $data;
                     }
                     foreach ($delegates as $delegate => $extensions) {
                         $tt = $tq = 0;
                         $te = array();
                         $row = new XMLElement('tr');
                         $row->appendChild(new XMLElement('th', $delegate));
                         $table->appendChild($row);
                         foreach ($extensions as $extension) {
                             $execution_time = number_format($extension[1], 4);
                             $extension_row = new XMLElement('tr');
                             // Poor man's grouping.
                             $extension_row->appendChild(new XMLElement('td', '&nbsp;'));
                             $extension_row->appendChild(new XMLElement('th', $extension[0]));
                             $extension_row->appendChild(new XMLElement('td', $execution_time . ' s from ' . $extension[4] . ' ' . ($extension[4] == 1 ? 'query' : 'queries')));
                             $table->appendChild($extension_row);
                             $tt += $execution_time;
                             $tq += is_array($extension[4]) ? count($extension[4]) : $extension[4];
                             if (!in_array($extension[0], $te)) {
                                 $te[] = $extension[0];
                             }
                         }
                         $row->appendChild(new XMLElement('td', number_format($tt, 4) . ' s from ' . count($te) . ' extensions and ' . $tq . ' ' . ($tq == 1 ? 'query' : 'queries')));
                     }
                 } else {
                     if ($this->_records = $this->_records[$this->_view]) {
                         $ds_total = 0;
                         foreach ($this->_records as $data) {
                             $row = new XMLElement('tr');
//.........这里部分代码省略.........
开发者ID:hotdoy,项目名称:EDclock,代码行数:101,代码来源:content.profile.php

示例11: appendFormattedElement

 function appendFormattedElement(&$wrapper, $data)
 {
     $item = new XMLElement($this->get('element_name'));
     $item->setAttributeArray(array('size' => General::formatFilesize(filesize(WORKSPACE . $data['file'])), 'path' => str_replace(WORKSPACE, NULL, dirname(WORKSPACE . $data['file'])), 'type' => $data['mimetype'], 'signature' => $data['signature']));
     $item->appendChild(new XMLElement('filename', General::sanitize(basename($data['file']))));
     $m = unserialize($data['meta']);
     if (is_array($m) && !empty($m)) {
         $item->appendChild(new XMLElement('meta', NULL, $m));
     }
     $wrapper->appendChild($item);
 }
开发者ID:bauhouse,项目名称:sym-extensions,代码行数:11,代码来源:field.signedfileupload.php

示例12: foreach

					</td>
				</tr>
			</tfoot>
			<tbody>

<?php 
if (!empty($files) && is_array($files)) {
    $bEven = false;
    foreach ($files as $row) {
        $handle = "/" . trim($row['path'], "/") . "/" . $row['name'];
        $handle = preg_replace('/\\/{2,}/', "/", $handle);
        $abs_filename = WORKSPACE . $handle;
        $filename = URL . "/workspace" . $handle;
        $file_cell_handle = str_replace($row['name'], "", $handle);
        $file_cell_handle = "/" . ltrim($file_cell_handle, "/");
        $file_size = General::formatFilesize(filesize($abs_filename));
        $downloads = $recorded_files[$handle]['downloads'];
        if (empty($downloads)) {
            $downloads = 0;
        } else {
            $downloads = "<strong>{$downloads}</strong>";
        }
        ?>
				<tr<?php 
        print $bEven ? ' class="even"' : "";
        ?>
>
					<td><a href="<?php 
        print $filename;
        ?>
" class="content"><?php 
开发者ID:symphonycms,项目名称:symphony-1.7,代码行数:31,代码来源:sym_publish_filemanager.php

示例13: checkPostFieldData

 public function checkPostFieldData($data, &$message, $entry_id = NULL)
 {
     /**
      * For information about PHPs upload error constants see:
      * @link http://php.net/manual/en/features.file-upload.errors.php
      */
     $message = null;
     if (empty($data) || is_array($data) && isset($data['error']) && $data['error'] == UPLOAD_ERR_NO_FILE) {
         if ($this->get('required') == 'yes') {
             $message = __('‘%s’ is a required field.', array($this->get('label')));
             return self::__MISSING_FIELDS__;
         }
         return self::__OK__;
     }
     // Its not an array, so just retain the current data and return
     if (is_array($data) === false) {
         /**
          * Ensure the file exists in the `WORKSPACE` directory
          * @link http://symphony-cms.com/discuss/issues/view/610/
          */
         $file = WORKSPACE . preg_replace(array('%/+%', '%(^|/)\\.\\./%'), '/', $data);
         //var_dump($data['file']);
         if (file_exists($file) === false || !is_readable($file)) {
             $message = __('The file uploaded is no longer available. Please check that it exists, and is readable.');
             return self::__INVALID_FIELDS__;
         }
         // Ensure that the file still matches the validator and hasn't
         // changed since it was uploaded.
         if ($this->get('validator') != null) {
             $rule = $this->get('validator');
             if (General::validateString($file, $rule) === false) {
                 $message = __('File chosen in ‘%s’ does not match allowable file types for that field.', array($this->get('label')));
                 return self::__INVALID_FIELDS__;
             }
         }
         return self::__OK__;
     }
     if (is_dir(DOCROOT . $this->get('destination') . '/') === false) {
         $message = __('The destination directory, %s, does not exist.', array('<code>' . $this->get('destination') . '</code>'));
         return self::__ERROR__;
     } else {
         if (is_writable(DOCROOT . $this->get('destination') . '/') === false) {
             $message = __('Destination folder is not writable.') . ' ' . __('Please check permissions on %s.', array('<code>' . $this->get('destination') . '</code>'));
             return self::__ERROR__;
         }
     }
     if ($data['error'] != UPLOAD_ERR_NO_FILE && $data['error'] != UPLOAD_ERR_OK) {
         switch ($data['error']) {
             case UPLOAD_ERR_INI_SIZE:
                 $message = __('File chosen in ‘%1$s’ exceeds the maximum allowed upload size of %2$s specified by your host.', array($this->get('label'), is_numeric(ini_get('upload_max_filesize')) ? General::formatFilesize(ini_get('upload_max_filesize')) : ini_get('upload_max_filesize')));
                 break;
             case UPLOAD_ERR_FORM_SIZE:
                 $message = __('File chosen in ‘%1$s’ exceeds the maximum allowed upload size of %2$s, specified by Symphony.', array($this->get('label'), General::formatFilesize($_POST['MAX_FILE_SIZE'])));
                 break;
             case UPLOAD_ERR_PARTIAL:
             case UPLOAD_ERR_NO_TMP_DIR:
                 $message = __('File chosen in ‘%s’ was only partially uploaded due to an error.', array($this->get('label')));
                 break;
             case UPLOAD_ERR_CANT_WRITE:
                 $message = __('Uploading ‘%s’ failed. Could not write temporary file to disk.', array($this->get('label')));
                 break;
             case UPLOAD_ERR_EXTENSION:
                 $message = __('Uploading ‘%s’ failed. File upload stopped by extension.', array($this->get('label')));
                 break;
         }
         return self::__ERROR_CUSTOM__;
     }
     // Sanitize the filename
     $data['name'] = Lang::createFilename($data['name']);
     if ($this->get('validator') != null) {
         $rule = $this->get('validator');
         if (!General::validateString($data['name'], $rule)) {
             $message = __('File chosen in ‘%s’ does not match allowable file types for that field.', array($this->get('label')));
             return self::__INVALID_FIELDS__;
         }
     }
     return self::__OK__;
 }
开发者ID:nitriques,项目名称:enhanced_upload_field,代码行数:78,代码来源:field.enhanced_upload.php

示例14: buildTableRow

 public function buildTableRow(DirectoryIterator $file, $includeParentDirectoryDots = true)
 {
     if (!$file->isDot() && substr($file->getFilename(), 0, 1) == '.' && Administration::instance()->Configuration->get('show-hidden', 'filemanager') != 'yes') {
         return;
     } elseif ($file->isDot() && !$includeParentDirectoryDots && $file->getFilename() == '..') {
         return;
     } elseif ($file->getFilename() == '.') {
         return;
     }
     $relpath = str_replace($this->getStartLocation() == '' ? DOCROOT : DOCROOT . $this->getStartLocation(), NULL, $file->getPathname());
     if (!$file->isDir()) {
         //if(File::fileType($file->getFilename()) == self::CODE)
         //	$download_uri = self::baseURL() . 'edit/?file=' . urlencode($relpath);
         //else
         $download_uri = self::baseURL() . 'download/?file=' . urlencode($relpath);
     } else {
         $download_uri = self::baseURL() . 'properties/?file=' . urlencode($relpath) . '/';
     }
     if (!$file->isDot()) {
         $td1 = Widget::TableData(Widget::Anchor($file->getFilename(), self::baseURL() . ($file->isDir() ? 'browse' . $relpath . '/' : 'properties/?file=' . urlencode($relpath)), NULL, 'file-type ' . ($file->isDir() ? 'folder' : File::fileType($file->getFilename()))));
         //$group = (function_exists('posix_getgrgid') ? posix_getgrgid($file->getGroup()) : $file->getGroup());
         //$owner = (function_exists('posix_getpwuid') ? posix_getpwuid($file->getOwner()) : $file->getOwner());
         $group = $file->getGroup();
         $owner = $file->getOwner();
         $td3 = Widget::TableData(File::getOctalPermission($file->getPerms()) . ' <span class="inactive">' . File::getReadablePerm($file->getPerms()), NULL, NULL, NULL, array('title' => (isset($owner['name']) ? $owner['name'] : $owner) . ', ' . (isset($group['name']) ? $group['name'] : $group)) . '</span>');
         $td4 = Widget::TableData(DateTimeObj::get(__SYM_DATETIME_FORMAT__, $file->getMTime()));
         if ($file->isWritable()) {
             if ($file->isDir()) {
                 $td5 = Widget::TableData(Widget::Anchor('Edit', $download_uri));
             } else {
                 $td5 = Widget::TableData(Widget::Anchor('Download', $download_uri));
             }
         } else {
             $td5 = Widget::TableData('-', 'inactive');
         }
     } else {
         $td1 = Widget::TableData(Widget::Anchor('&crarr;', self::baseURL() . 'browse' . $relpath . '/'));
         $td3 = Widget::TableData('-', 'inactive');
         $td4 = Widget::TableData('-', 'inactive');
         $td5 = Widget::TableData('-', 'inactive');
     }
     $td2 = Widget::TableData($file->isDir() ? '-' : General::formatFilesize($file->getSize()), $file->isDir() ? 'inactive' : NULL);
     $startlocation = DOCROOT . $this->getStartLocation();
     if (!$file->isDot()) {
         $td5->appendChild(Widget::Input('items[' . str_replace($startlocation, '', $file->getPathname()) . ($file->isDir() ? '/' : NULL) . ']', NULL, 'checkbox'));
     }
     return Widget::TableRow(array($td1, $td2, $td3, $td4, $td5));
 }
开发者ID:bauhouse,项目名称:sym-extensions,代码行数:48,代码来源:extension.driver.php

示例15: appendFormattedElement

 public function appendFormattedElement(&$wrapper, $data, $encode = false, $mode = null, $entry_id = null)
 {
     if (!$this->sanitizeDataArray($data)) {
         return null;
     }
     $item = new XMLElement($this->get('element_name'));
     $item->setAttributeArray(array('size' => General::formatFilesize($data['size']), 'type' => General::sanitize($data['mimetype']), 'name' => General::sanitize($data['name'])));
     $item->appendChild(new XMLElement('path', str_replace(WORKSPACE, NULL, dirname(WORKSPACE . $data['file']))));
     $item->appendChild(new XMLElement('file', General::sanitize(basename($data['file']))));
     $meta = unserialize($data['meta']);
     if (is_array($meta) and !empty($meta)) {
         $item->appendChild(new XMLElement('meta', null, $meta));
     }
     ###
     # Delegate: UploadField_AppendFormattedElement
     # Description: Allow other extensions to add media previews.
     $this->Symphony->ExtensionManager->notifyMembers('UploadField_AppendFormattedElement', '/frontend/', array('data' => $data, 'entry_id' => $entry_id, 'field_id' => $this->get('id'), 'wrapper' => $item));
     $wrapper->appendChild($item);
 }
开发者ID:psychoticmeowArchives,项目名称:uploadfield,代码行数:19,代码来源:field.upload.php


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