Пример #1
0
 public function testGetRowData()
 {
     $db = JFactory::getDbo();
     $db->setQuery('SELECT * FROM ' . $db->quoteName('#__users') . ' WHERE ' . $db->quoteName('id') . ' = ' . (int) 42);
     $arrayFromQuery = $db->loadAssoc();
     $testTable = new JTableUser(self::$driver);
     $testTable->load(42);
     $arrayFromMethod = $this->object->getRowData($testTable);
     $this->assertEquals($arrayFromQuery, $arrayFromMethod);
 }
Пример #2
0
 /**
  * Gets a row of data from a table
  *
  * @param   JTable  $table  JTable instance for a row.
  *
  * @return  array  Associative array of all columns and values for a row in a table.
  *
  * @since   3.1
  */
 public function getRowData(JTable $table)
 {
     $data = new JHelper();
     return $data->getRowData($table);
 }
Пример #3
0
 /**
  * Get the sha1 hash value for the current item being edited.
  *
  * @return  string  sha1 hash of row data
  *
  * @since   3.2
  */
 protected function getSha1Hash()
 {
     $result = false;
     $typeTable = JTable::getInstance('Contenttype', 'JTable');
     $typeId = JFactory::getApplication()->input->getInteger('type_id', 0);
     $typeTable->load($typeId);
     $typeAliasArray = explode('.', $typeTable->type_alias);
     JTable::addIncludePath(JPATH_ROOT . '/administrator/components/' . $typeAliasArray[0] . '/tables');
     $contentTable = $typeTable->getContentTable();
     $keyValue = JFactory::getApplication()->input->getInteger('item_id', 0);
     if ($contentTable && $contentTable->load($keyValue)) {
         $helper = new JHelper();
         $dataObject = $helper->getDataObject($contentTable);
         $result = $this->getTable('Contenthistory', 'JTable')->getSha1(json_encode($dataObject), $typeTable);
     }
     return $result;
 }
Пример #4
0
 /**
  * 根据图片URL按规格生成大小图片
  * @param $url 原始图片URL(绝对地址)
  * @param $dsc 新图片相对地址
  * @param $size 新图片尺寸
  * @param $mode 处理图片模式1,普通,2补白
  * @return void
  */
 public static function thumbnail($url, $dsc, $size = '50x50', $mode = 1)
 {
     require_once 'HTTP/Request.php';
     //如果目标图已经存在退出
     $req = new HTTP_Request(JHelper::vfsUrl($dsc));
     $req->sendRequest();
     $dscData = $req->getResponseBody();
     if ($req->_response->_code != 404 && $dscData) {
         return;
     }
     //判断原图是否存在
     $req = new HTTP_Request($url);
     $req->sendRequest();
     $data = $req->getResponseBody();
     if (!$data) {
         return;
     }
     $tmpSrc = tempnam($_SERVER['CACHE_DIR'], 'src');
     file_put_contents($tmpSrc, $data);
     $imk = new JImagick($tmpSrc);
     $imk->thumbnail($size, $mode);
     $tmpDsc = tempnam($_SERVER['CACHE_DIR'], 'dsc');
     $imk->save($tmpDsc);
     //写vfs
     $vfs = new JVfs();
     $vfs->rsyncWrite($dsc, $tmpDsc, true);
     @unlink($tmpSrc);
     @unlink($tmpDsc);
 }